You are viewing the documentation for Blueriq 16. Documentation for other versions is available in our documentation directory.

A note on collections and duplicates

An expression resulting in a collection does not contain duplicates. Please be aware however, that intermediary results of a COLLECT statement can contain duplicates. You have to be aware of this when using the SIZE or UNPACK function, or when using TSL.

This is best illustrated with the following examples.

Person instancePerson.NamePerson.Age
Person_1Kim24
Person_2Rick25
Person_3Bob25
ExpressionResultTypeNote
COLLECT Person.Age FROM ALL Person[ 24 , 25 ]String (multivalued)
SIZE ( COLLECT Person.Age FROM ALL Person )3IntegerThe intermediary collection is [ 24, 25, 25 ]

 TSL:

The ages present are: [[[ COLLECT Person.Age FROM ALL Person ]]].

The ages present are: 24, 25, 25.StringThe intermediary collection is [ 24, 25, 25 ]
SIZE ( UNIQUE ( COLLECT Person.Age FROM ALL Person ) )2IntegerThe duplicates in the intermediary collection are filtered by the UNIQUE function


Now an example with the UNPACK function. We leave out the first instance from the previous example.

Person instancePerson.NamePerson.Age
Person_2Rick25
Person_3Bob25
ExpressionResultTypeNote
COLLECT Person.Age FROM ALL Person[ 25 ]Integer (multivalued)
UNPACK ( COLLECT Person.Age FROM ALL Person )Error
The collection contains 2 elements [ 25 , 25 ]
UNPACK ( UNIQUE ( COLLECT Person.Age FROM ALL Person ) )25


 Only the intermediary results of a COLLECT statement can contain duplicates. The functions UNIQUE, UNION, INTERSECTION, DIFFERENCE and SYMMETRIC_DIFFERENCE always return collections without duplicates.

Back to Top