Skip to content

Commit 3cd1ba5

Browse files
wip
1 parent 1e060c7 commit 3cd1ba5

2 files changed

Lines changed: 2 additions & 15 deletions

File tree

datafusion/core/tests/physical_optimizer/filter_pushdown.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,10 +3147,6 @@ fn test_pushdown_with_empty_group_by() {
31473147

31483148
#[test]
31493149
fn test_pushdown_through_aggregate_with_reordered_input_columns() {
3150-
// Test filter pushdown through aggregate when a ProjectionExec below the
3151-
// aggregate reorders columns, causing input indices to differ from output indices.
3152-
// This reproduces the bug where grouping_columns were built from input schema
3153-
// positions rather than output schema positions.
31543150
let scan = TestScanBuilder::new(schema()).with_support(true).build();
31553151

31563152
// Reorder scan output from (a, b, c) to (c, a, b)

datafusion/physical-plan/src/aggregates/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,8 +1479,7 @@ impl ExecutionPlan for AggregateExec {
14791479
// INPUT columns which may have different indices (e.g., when an intermediate
14801480
// ProjectionExec reorders columns). We must compare in the same index space.
14811481
let output_schema = self.schema();
1482-
let num_grouping_cols = self.group_by.expr().len();
1483-
let grouping_columns: HashSet<_> = (0..num_grouping_cols)
1482+
let grouping_columns: HashSet<_> = (0..self.group_by.expr().len())
14841483
.map(|i| Column::new(output_schema.field(i).name(), i))
14851484
.collect();
14861485

@@ -1503,18 +1502,10 @@ impl ExecutionPlan for AggregateExec {
15031502

15041503
// For GROUPING SETS, verify this filter's columns appear in all grouping sets
15051504
if self.group_by.groups().len() > 1 {
1506-
// Map filter columns to their grouping expression index via output position
15071505
let filter_column_indices: Vec<usize> = filter_columns
15081506
.iter()
15091507
.filter_map(|filter_col| {
1510-
if filter_col.index() < num_grouping_cols
1511-
&& output_schema.field(filter_col.index()).name()
1512-
== filter_col.name()
1513-
{
1514-
Some(filter_col.index())
1515-
} else {
1516-
None
1517-
}
1508+
grouping_columns.get(filter_col).map(|col| col.index())
15181509
})
15191510
.collect();
15201511

0 commit comments

Comments
 (0)