COLLECT_LIST
Description
The collect_list function is used to collect and return an array from a set of input data. Users can optionally use the distinct keyword to return a set without duplicate elements.
Parameter Description
- expr: An expression of any type, used to collect elements from the input data.
Return Result
- Returns an array where the element type is the same as the input parameter type.
- If the distinct keyword is set, a deduplicated set is returned.
- The function does not guarantee the order of elements in the return result.
- If the input data contains null values, null will not be included in the calculation.
Usage Example
-
Return an array containing non-duplicate elements:
-
Return an array containing duplicate elements:
-
Collecting Characters from String Data:
-
Collect and return an array containing null values: