The ArrayAgg joins a given column's row values into a single array. Each window of values within a column will be aggregated into an individual array.

Not all warehouses support this function; check the Limitations section in the corresponding Connect to ... document.

ArrayAgg ignores all Null input values; if all values in the input are Null, Sigma returns an empty list.

Sort the initial input column of values to subsequently sort the resulting aggregated array. If no sort is applied to the initial column, the resulting array's order of values is unpredictable.

You can use the ArrayAgg function on BigQuery,Β PostgreSQL, Databricks, Snowflake, and AlloyDBΒ connections.

Syntax

ArrayAgg(column\_name)

The function has the following argument:

column_name
Required
The column of values to combine

Example

ArrayAgg(\[County\])

A table contains a grouped [State] column and an associated [County] column. You can use the ArrayAgg function to create an array of all counties within each state.


Related resources