Skip to main content

compute_output_order

Function compute_output_order 

Source
pub fn compute_output_order(
    projection: &[SelectItem],
    group_by: &[SqlExpr],
    functions: &FunctionRegistry,
    scope: &TableScope,
) -> Result<Vec<AggOutputSlot>>
Expand description

Walk projection in output order and classify each item as a GROUP BY key slot or an aggregate slot, producing the interleaving that output_schema replays to emit columns in SELECT-list order.

group_by is the canonical key list; AggOutputSlot::GroupKey indexes it. Real aggregates are numbered in projection order from 0; GROUPING(col) pseudo-aggregates are numbered after all real aggregates, mirroring how the planner appends them to the aggregate list. Items that are neither a bare group key nor an aggregate (a bare non-key expression) produce no slot — they have no output column in the aggregate result today.