Skip to content
Closed
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
10 changes: 10 additions & 0 deletions src/snowflake/snowpark/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7005,6 +7005,16 @@ def array_agg(
"""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 :meth:`Column.within_group`
on the aggregate expression. Sorting the result DataFrame orders result
rows, not the elements inside each array. This also applies to the
``collect_list`` alias. When ``is_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``::

>>> ordered_values = array_agg("a").within_group("a")

Example::
>>> df = session.create_dataframe([[1], [2], [3], [1]], schema=["a"])
>>> df.select(array_agg("a", True).within_group("a").alias("result")).show()
Expand Down
Loading