Evaluate to return unique values from array fields


I have a type like the following:

entity type TypeA schema name "TYPEA" {

    codes: ["USA, "CAN", "BRT"] schema suffix "CD"


What is the proper evaluate spec to return the unique values from the array across all records of the type? The following returns nulls:

TypeA.evaluate({projection: "unique(countries)")})

I couldn’t find an expression that would help me concatenate or flatten such arrays (concat in the expression did not help).

One option is to persist these codes, but that seems wasteful and unnecessary.


Unfortunately evaluate doesn’t support what you are trying to do. The “unique” function in a projection when applied to an array/mapp is a non-aggregating function and only uniqueifies the individual arrays/mapps in each obj.