object_agg¶
Description¶
Extract aggregated fields and values from a group of rows into a new JSON object.
Returns one OBJECT per group.
For each (key, value) input pair, the resulting object contains a key:value field. The key column needs to be string. Duplicate keys within a group result in an error, and input tuples with NULL key and/or value are ignored.
Return type¶
object
Domain¶
This is an aggregate function (aggregates rows over a group in aggregate verbs.)
This is a window function (calculates over a group of multiple input rows using windowing.)
Categories¶
Usage¶
object_agg(key, value)
Argument |
Type |
Optional |
Repeatable |
Restrictions |
---|---|---|---|---|
key |
string |
no |
no |
none |
value |
storable |
no |
no |
none |
Examples¶
statsby clusterid, oa:object_agg(jobid, status), group_by(clusterid)
For each clusterid, return a JSON object containing the status of each jobid with the attached clusterid.