snowflake.snowpark.functions.collect_set¶

snowflake.snowpark.functions.collect_set(col: Union[Column, str]) → Column[source]¶

Returns a Column containing the distinct values in the specified column col. The values in the Column are in no particular order, and the order is not deterministic. The function ignores NULL values in col. If col contains only NULL values or col is empty, the function returns an empty Column.

Parameters:

col – A Column object or column name that determines the values.

Example::
>>> df = session.create_dataframe([[5], [2], [1], [2], [1]], schema=["a"])
>>> df.select(array_unique_agg("a").alias("result")).show()
------------
|"RESULT"  |
------------
|[         |
|  5,      |
|  2,      |
|  1       |
|]         |
------------
Copy