Language

Projection and Aliases

Projection selects fields from the input payload.

Guide

Projection selects fields from the input payload.

sql
SELECT category, region INTO output FROM input

Tested input:

jsonl
{"category":"a","region":"east"}
{"category":"b","region":"west"}

Tested output:

jsonl
{"category":"a","region":"east"}
{"category":"b","region":"west"}

Nested Fields

Nested paths use dot notation:

sql
SELECT field1.field2.field3.field4.field5 INTO output FROM input

Qualified paths may include the input name:

sql
SELECT input.field1.field2.field3.field4.field5 INTO output FROM input

Aliases

Aliases rename projected fields:

sql
SELECT value AS v, category AS c INTO output FROM input

Tested input:

json
{"value":5,"category":"x"}

Tested output behavior:

json
{"v":5,"c":"x"}

Aliases can produce nested output paths by using bracketed names:

sql
SELECT field1.field2.field3 AS [a.b.c] INTO output FROM input

Tested output behavior:

json
{"a":{"b":{"c":42}}}

Nested source fields can also be merged:

sql
SELECT field1.field2, field1.field3 INTO output FROM input

Tested input:

json
{"field1":{"field2":10,"field3":20}}

Tested output behavior:

json
{"field1":{"field2":10,"field3":20}}

If duplicate aliases are used, the last projection wins:

sql
SELECT value AS x, category AS x INTO output FROM input

Tested input:

json
{"value":5,"category":"cat"}

Tested output behavior:

json
{"x":"cat"}

Scalar Function Projection

Scalar or aggregate function projections require aliases. The tests include:

sql
SELECT ABS(value) AS absValue INTO output FROM input

and reject:

sql
SELECT ABS(value) INTO output FROM input

The test suite also contains a scalar projection shaped as:

sql
SELECT avg(value) AS absValue INTO output FROM input

This query is accepted because the function projection has an alias.