snowflake.snowpark.functions.collect_list¶
- snowflake.snowpark.functions.collect_list(col: Union[Column, str], is_distinct: bool = False) Column[source]¶
Returns the input values, pivoted into an ARRAY. If the input is empty, an empty ARRAY is returned.
Element order is unpredictable unless you specify
Column.within_group()on the aggregate expression. Sorting the result DataFrame orders result rows, not the elements inside each array. This also applies to thecollect_listalias. Whenis_distinct=True, the ordering expression must refer to the same column as the aggregate input.For example, this expression orders elements within each array by
a:- Example::
collect_listis an alias ofarray_aggwith the same arguments and behavior. The two names share this documentation, which is why the example above usesarray_agg. By default, duplicates are retained.This example produces an array containing
[1, 2, 2]:Example using the alias: