Map, filter & aggregate with TRANSFORM()

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
    WITH (
        WITH [...internal field definitions]
        SELECT [...fields to return including group bys]
        WHERE [...final filter, equivalent of having]
        ORDER BY [...sort expressions]
        OFFSET [...skip rows]
        LIMIT [...max rows]
    )
    IMPORTING [...imported features]
)
sql

You can:

  • SELECT ...: generate new fields from existing fields
  • WHERE ...: filter post aggregation
  • ... FILTER (WHERE ...) GROUP BY ...: aggregate filtered data
  • ORDER BY ...: sort data
  • LIMIT ...: limit the number of rows returned
  • OFFSET ...: skip the first n rows

The transformation query must be self contained.

Therefore, you cannot perform the following operations inside the TRANSFORM() query:

  • Reference data outside of the array of rows,
  • Join with external tables or fields, so no EXTEND() on fields,
  • Nest other TRANSFORM().

You need to perform these operations from the outside of the TRANSFORM() query. See examples here.

Example usage

Here are examples demonstrating practical cases:

Last update at: 2025/12/05 16:03:14
Last updated: 2025-12-05 16:07:55