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 instance | Person.Name | Person.Age |
---|
Person_1 | Kim | 24 | Person_2 | Rick | 25 | Person_3 | Bob | 25 |
Expression | Result | Type | Note |
---|
COLLECT Person.Age FROM ALL Person | [ 24 , 25 ] | String (multivalued) |
| SIZE ( COLLECT Person.Age FROM ALL Person ) | 3 | Integer | The intermediary collection is [ 24, 25, 25 ] | TSL: The ages present are: [[[ COLLECT Person.Age FROM ALL Person ]]]. | The ages present are: 24, 25, 25. | String | The intermediary collection is [ 24, 25, 25 ] | SIZE ( UNIQUE ( COLLECT Person.Age FROM ALL Person ) ) | 2 | Integer | The 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 instance | Person.Name | Person.Age |
---|
Person_2 | Rick | 25 | Person_3 | Bob | 25 |
Expression | Result | Type | Note |
---|
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 |
|
|
UI Text Box |
---|
| 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. |
|