ARRAY_UNION_AGG
functionsupportedCore SQL functionsReturns an ARRAY that contains the union of the distinct values from the input arrays in a column. You can use this to aggregate distinct values in arrays produced by ARRAY_UNIQUE_AGG.
Syntax
supportedpartialnot supportednot scored
Aggregate function
ARRAY_UNION_AGG( <column> )
Window function
ARRAY_UNION_AGG( <column> ) OVER ( [ PARTITION BY <expr> ] )
Parameters
| Name | Required | Description |
|---|---|---|
column | required | The column containing the arrays with the distinct values (the arrays produced by ARRAY_UNIQUE_AGG). |
Returns
The function returns an array containing the distinct values from the arrays in column. The values in the array are in no particular order, and the order is not deterministic. Note that this function uses multiset semantics, which means that the maximum number of occurrences of an individual value in a single input array determines the number of occurrences of that value in the output array. See Examples. The function ignores NULL values in column and in the arrays in column. If column contains only NULL values or the table containing column is empty, the function returns an empty array.
Usage notes
- This function can be used as either of the following types of functions: aggregate function
- window function.
- When this function is called as a window function, it does not support explicit window frames.
- When you pass a structured array to the function, the function returns a structured array of the same type.