prql icon indicating copy to clipboard operation
prql copied to clipboard

Struct syntax

Open max-sixty opened this issue 2 years ago • 0 comments

For creating "structs" / "objects" / "composite types" — e.g. snowflake objects, postgres composite types, bigquery structs, what do people think of syntax?

We could use brackets for this:

from employees
derive name: {first_name, last_name}
derive name_concise: {first: first_name, last: last_name}

Possibly structs aren't created that much and we don't want to expend brackets on them. In which case we could just use as and do something different for struct rather than other types (currently it just casts:

from employees
derive name: ([first_name, last_name] | as struct)
derive name_concise: ([first: first_name, last: last_name] | as struct)

Or very open to other ideas

max-sixty avatar Apr 29 '22 22:04 max-sixty