- Categories:
Aggregate functions (Semi-structured Data) , Window functions (General) , Semi-structured and structured data functions (Array/Object)
OBJECT_AGG¶
Returns one OBJECT per group. For each (key, value) input pair, where key
must be a VARCHAR and value must be a VARIANT, the resulting OBJECT contains
a key:value field.
- Aliases:
OBJECTAGG
Syntax¶
Aggregate function
Window function
Usage notes¶
Input tuples with NULL
keyand/orvalueare ignored.Duplicate keys within a group result in a
Duplicate field key 'key'error.The DISTINCT keyword is supported, but it only filters out duplicate rows where both
keyandvalueare equal.
When this function is called as a window function, it does not support:
An ORDER BY clause within the OVER clause.
Explicit window frames.
Examples¶
This example uses OBJECT_AGG as an aggregate function: