Repository navigation
test: add planner tests for ordering, constant and equality facts - #26570
Merged
jayzhan211 merged 2 commits intoOct 23, 2026
Merged
Conversation
jayzhan211
marked this pull request as ready for review
October 21, 2026 14:47
zhuqi-lucas
approved these changes
Oct 23, 2026
Contributor
Author
|
Thanks @zhuqi-lucas ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
The planner skips sorts and keeps streaming execution when it can prove that the data already has the needed
order. It decides this from what each plan node knows about its output: which orderings hold, which columns are
constant, and which columns are equal. Several of these decisions have no test today:
Two open PRs show why this matters. #26459 and #26042 change how constants pass through outer joins. Cross
join derives its output facts as if it were a full outer join, so both would make cross-join queries sort on
columns that are still constant, and no existing test fails. The cross-join cases added here fail with either PR
merged in.
Without tests, a change to how the planner tracks these facts could add sorts, change the aggregation mode, or
make a streaming query fail to plan, and nothing would catch it. This PR pins the plans that main produces today.
What changes are included in this PR?
A new
datafusion/sqllogictest/test_files/equivalence_properties.slt, with one comment per case that says whichplanner decision it pins:
ain a different column is still known to be sorted bya.GROUP BY d, c, b, aover data sorted by(a, b)and bycfindsc, a, bsorted and runs in partiallysorted mode on them.
ORDER BY ... LIMIT, so an outer sort that starts with that constant is removed.partitioned by that cast needs no sort.
In
datafusion/core/tests/physical_optimizer/enforce_distribution.rs, a new test checks that sort-merge joinkeys are realigned to a range partitioning when the second of two orderings of an unbounded input matches it, not
only the first. The existing
ordered_streamhelper now takes a list of orderings so the new test can reuse it.What is the testing strategy for this PR?
This PR adds tests only. All new cases pass on the current main branch, and the new sqllogictest file gives the
same result over repeated runs.
Are there any user-facing changes?
No.