Objects
$$ROOT
Specifying $$ROOT as a column alias sets the value to root object but only works with aggregates (unless contained in array sub select). This is useful when you want to return the root object as a column.
Example $$ROOT usage
Merge Fields into Object
Only available in aggregates. Use a SELECT without specifying a table to create a new object.
Create a new Object and assign to root
Creating a new object and assigning to root
Supported Object Functions
PARSE_JSON
PARSE_JSON(expr)
Parses the JSON string. Use in conjunction with ARRAY_TO_OBJECT to convert an array to an object.
Example PARSE_JSON usage
MERGE_OBJECTS
MERGE_OBJECTS(expr)
Example MERGE_OBJECTS usage
Example MERGE_OBJECTS usage with sub select
EMPTY_OBJECT
EMPTY_OBJECT()
Creates an empty object.
Example EMPTY_OBJECT usage
Example EMPTY_OBJECT usage in a condition
FLATTEN
FLATTEN(field, prefix)
Flattens an object into a set of fields. You can optionally add a
Example FLATTEN usage
``sql'
SELECT
id,
FLATTEN(address,'addr_')
FROMcustomers`;
???+ example "Example `FLATTEN` usage with unset"
```sql'
SELECT
id,
FLATTEN(`address`,'addr_',true)
FROM `customers`;
Will remove the
addressfield from the output and will only have theaddr_prefixed fields.