snowflake.snowpark.functions.array_union_agg

snowflake.snowpark.functions.array_union_agg(col: Union[Column, str]) Column[source]

Returns an ARRAY that contains the union of the distinct values from the input arrays in the specified column.

The values in the returned ARRAY are in no particular order, and the order is not deterministic. The function ignores NULL values in the column and in arrays in the column. If the column contains only NULL values or the input is empty, the function returns an empty ARRAY.

Parameters:

col – A Column object or column name containing arrays with distinct values.

Example::
>>> import re
>>> df = session.create_dataframe([[[1, 1, 2]], [[1, 2, 3]]], schema=["a"])
>>> row = df.select(array_union_agg("a").alias("result")).collect()[0]
>>> sorted(int(i) for i in re.findall(r"\d+", row[0]))
[1, 1, 2, 3]