malloy
malloy copied to clipboard
Pivots that are all measures need to show the pivot name.
In the first query, we dont' see the column names for the pivots and we should. The unique thing here is that the pivots are all measures so it really isn't quite a pivot...
source: airports is duckdb.table('../data/airports.parquet') extend {
measure:
airport_count is count()
average_elevation is elevation.avg()
view:
metrics is {aggregate: airport_count, average_elevation}
}
run: airports ->
{group_by: fac_type} + metrics
+ {
# pivot
nest:
ny is metrics + {where: state='NY'}
ca is metrics + {where: state='CA'}
}
run: airports ->
{group_by: fac_type} + metrics
+ {
# pivot
nest:
by_state is {
where: state = 'CA' | 'NY'
group_by: state
} + metrics
}