You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(physical-optimizer): decline eager aggregation for grouping-set aggregates
`EagerAggregation` rebuilds the top grouping with
`PhysicalGroupBy::new_single`, which cannot express `null_expr`, `groups`,
or `has_grouping_set`. Applied to a `GROUPING SETS`/`ROLLUP`/`CUBE`
aggregate it therefore returns a plain grouping, dropping both the
grouping-set rows and the `__grouping_id` column that `group_fields`
appends for them.
The rule opts out of `schema_check` (COUNT->SUM widens non-null to
nullable), so nothing catches the narrowed output schema. A parent
projection or window keeps binding aggregate outputs at their original
indices and trips the `col.name() == matching_name` assertion in
`ProjectionMapping`:
Internal error: Assertion failed: col.name() == matching_name:
Input field name sum(store_sales.ss_ext_sales_price) does not match
with the projection expression sum(store_sales.ss_net_profit).
Decline the rewrite when the partial aggregate's grouping reports
`has_grouping_set()`. The guard is on the *partial* grouping because
`as_final` always clears the flag, folding `__grouping_id` into its
expression list, so the final aggregate's grouping cannot report it.
Adds two regression tests over the existing beneficial-join fixture,
grouped by `ROLLUP(d_name)` so the grouping set is the only difference:
one asserts no pre-aggregation is pushed, one asserts the aggregate
output schema (including `__grouping_id`) is unchanged. Both fail without
the guard. The plain-grouping fixture is reused via a new
`agg_over_join_grouped` helper, so the accept path stays covered.
Refs spiceai/spiceai#11827
0 commit comments