COLLECT_SET_ON_ARRAY
Description
The collect_set_on_array
function is used to extract unique elements from the input array expression and form a new array with these elements. When the distinct
keyword is specified, the function will perform deduplication on the result. However, please note that even if distinct
is not specified, the function itself has the deduplication feature, so the distinct
keyword will not have any additional effect in this scenario.
Parameter Description
expr
: The input array type expression.
Return Result
Returns an array where the element type is the same as the input array's element type. The order of elements in the result array is not guaranteed to be the same as the input array, and null
values in the array will not be included in the calculation.
Example
The following example demonstrates how to use the collect_set_on_array
function to process different input arrays and return the deduplicated result array.
Example 1:
Example 2:
Notes
- When the input array is entirely
null
, thecollect_set_on_array
function will return an empty array.