Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#### New Features

- Added support for the `array_union_agg` function in the `snowflake.snowpark.functions` module.

#### Bug Fixes

- Fixed a bug where `Session.udf.register_from_file` did not properly process the `strict` and `secure` parameters.
Expand Down
1 change: 1 addition & 0 deletions docs/source/snowpark/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Functions
array_sort
array_to_string
array_union
array_union_agg
array_unique_agg
arrays_overlap
arrays_zip
Expand Down
32 changes: 32 additions & 0 deletions src/snowflake/snowpark/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7450,6 +7450,38 @@ def array_to_string(
return _call_function("array_to_string", a, s, _emit_ast=_emit_ast)


@publicapi
def array_union_agg(col: ColumnOrName, _emit_ast: bool = True) -> Column:
"""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.

Args:
col: A :class:`Column` object or column name containing arrays with distinct values.

Example::
>>> df = session.create_dataframe([[[1, 1, 2]], [[1, 2, 3]]], schema=["a"])
>>> df.select(array_union_agg("a").alias("result")).show()
------------
|"RESULT" |
------------
|[ |
| 1, |
| 1, |
| 2, |
| 3 |
|] |
------------
<BLANKLINE>
"""
c = _to_col_if_str(col, "array_union_agg")
return _call_function("array_union_agg", c, _emit_ast=_emit_ast)


@publicapi
def array_unique_agg(col: ColumnOrName, _emit_ast: bool = True) -> Column:
"""Returns a Column containing the distinct values in the specified column col.
Expand Down
Loading
Loading