File tree Expand file tree Collapse file tree
datafusion/physical-plan/src/aggregates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1473,11 +1473,9 @@ impl ExecutionPlan for AggregateExec {
14731473 // This optimization is NOT safe for filters on aggregated columns (like filtering on
14741474 // the result of SUM or COUNT), as those require computing all groups first.
14751475
1476- // Build grouping columns using OUTPUT indices, not input indices.
1477- // Parent filters reference the AggregateExec's output schema where grouping
1478- // columns occupy positions [0..num_groups). The grouping expressions reference
1479- // INPUT columns which may have different indices (e.g., when an intermediate
1480- // ProjectionExec reorders columns). We must compare in the same index space.
1476+ // Build grouping columns using output indices because parent filters reference the AggregateExec's output schema where grouping
1477+ // columns in the output schema. The grouping expressions reference
1478+ // input columns which may not match the output schema.
14811479 let output_schema = self . schema ( ) ;
14821480 let grouping_columns: HashSet < _ > = ( 0 ..self . group_by . expr ( ) . len ( ) )
14831481 . map ( |i| Column :: new ( output_schema. field ( i) . name ( ) , i) )
You can’t perform that action at this time.
0 commit comments