Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Feb 9, 2026

Which issue does this PR close?

Rationale for this change

Wrong answers bug was introduced in 52

What changes are included in this PR?

Fix the bug with a big hammer: simply disable the whole optimizatio

Here is an alternative PR to just disable it in a more targeted setting

Are these changes tested?

Yes, a new test is added

Are there any user-facing changes?

A bug is fixed

@github-actions github-actions bot added documentation Improvements or additions to documentation development-process Related to development process of DataFusion physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) catalog Related to the catalog crate execution Related to the execution crate datasource Changes to the datasource crate physical-plan Changes to the physical-plan crate labels Feb 9, 2026
@alamb alamb force-pushed the alamb/fix_monotonic_sort_bug branch from 70f8863 to 91df46f Compare February 9, 2026 19:57
@alamb alamb changed the title Alamb/fix monotonic sort bug Fix group by sorting bug Feb 9, 2026
}
} else if maintains_input_order.is_empty()
|| !maintains_input_order.iter().any(|o| *o)
// Aggregate output columns can be computed expressions that are not
Copy link
Contributor Author

@alamb alamb Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty large hammer (just disables pushing grouping requirements through all AggregateExec`s convinced this is the best solution / correct yet

@alamb alamb changed the title Fix group by sorting bug Fix incorrect SortExec removal before AggregateExec Feb 9, 2026
@alamb alamb added optimizer Optimizer rules and removed documentation Improvements or additions to documentation development-process Related to development process of DataFusion physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate catalog Related to the catalog crate execution Related to the execution crate datasource Changes to the datasource crate physical-plan Changes to the physical-plan crate labels Feb 10, 2026
@alamb
Copy link
Contributor Author

alamb commented Feb 10, 2026

I am convinced we should go with option 2

@alamb alamb closed this Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect answers due to an incorrectly removed Sort before AggregateExec

1 participant