Arrays of rows
Here's an overview of working with arrays of ROW
types in FeatureQL.
Arrays of rows aren't a distinct type, but because they're central to entity centered modeling, FeatureQL has dedicated functions for working with them.
You can see the full list of array of rows functions in the Functions page.
Array of rows literals
Array of rows functions
Extractions
Concatenate two arrays of rows
Concatenate with optional deduplication on a field value.
Transform: map, filter, reduce as a subquery
The TRANSFORM()
function allows you to treat arrays of rows like mini tables and manipulate them using familiar FeatureQL syntax.
Here's the general structure:
TRANSFORM(
base
USING (
WITH [...internal field definitions]
SELECT [...fields to return including group bys]
WHERE ... [...final filter, equivalent of having]
ORDER BY ...
LIMIT ...
)
IMPORTING import_1, import_2...
)
sql
The transformation query must be self contained.
You cannot:
- Join with external tables or fields, so no ADD_FIELDS()
- Reference data outside of the
base
array - Nest other transforms()
If you need to incorporate external data, add it to your array of rows with ADD_FIELDS()
before applying TRANSFORM()
.
Example usage
Here are examples demonstrating practical cases: