efegokdemir opened a new pull request, #27667: URL: https://github.com/apache/datafusion/pull/27667
## Which issue does this PR close? Closes #27653. ## Rationale for this change With a unique key on the build side, the remaining sort keys are constant within each probe-key group. A partial sort can therefore wait for that group to end before returning the first row, even when the build key already determines those values. ## What changes are included in this PR? Propagate constraint-derived functional dependencies through joins and projections, and use them when checking whether an ordering is already satisfied. This lets the optimiser remove the redundant partial sort while preserving the required fetch and partition behaviour. Null-sensitive uniqueness is covered explicitly. ## What is the testing strategy for this PR? Added functional-dependency and physical-optimiser regression tests, and updated the affected group_by.slt plans. - cargo test --profile ci -p datafusion-physical-expr --lib unique --locked — 2 passed. - cargo test --profile ci -p datafusion --test core_integration physical_optimizer::enforce_sorting --locked — 144 passed. - cargo test --profile ci -p datafusion-sqllogictest --test sqllogictests -- group_by — 3 files passed. ## Are there any user-facing changes? Queries with a unique build key can return the first ordered row without waiting for the current probe-key group to finish. There are no public API changes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
