Repository navigation
fix: declare the input order of a native window over a sorted cache #7256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
comphead
wants to merge
12
commits into
apache:main
Choose a base branch
from
comphead:fix-window-declared-order-7223
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dc60097
fix: declare the input order of a native window over a sorted cache
comphead 5a3af5b
refactor: build the window's input order only where it is used
comphead c231e48
chore: trim comments and drop a window test the hash join test alread…
comphead 4508a55
test: cover WindowAggExec, nulls, descending keys and the collated fa…
comphead ca1a53a
fix: keep a stacked window's longer input order and declare it on emp…
comphead 0438a59
fix: declare a window's order next to a partial one its input declares
comphead fce10f0
refactor: send only a window's required order and merge overlapping t…
comphead e87d39a
fix: declare only a window's partition keys and fall back on an unche…
comphead ee88fd9
fix: keep a window's doubted order native, fall back on collated keys
comphead 1bb942a
fix: fall back on a collated window key only over a trusted order
comphead 3e991c7
Merge branch 'main' into fix-window-declared-order-7223
comphead 4eb2548
Merge branch 'main' into fix-window-declared-order-7223
comphead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This early return still drops a valid ordering above a left outer broadcast hash join. I sorted
range(12)byk = id % 3, projectedk AS a, k AS b, id AS v, and cached the result in one partition. I then left-joined a broadcast one-row table ona, kept both aliases in the output, and ransum(v) OVER (PARTITION BY a). Spark knowsaandbhave the same order and returns all 12 rows (group sums18, 22, 26). The native join declares its probe ordered byb, and the window sendsa, butkeeps_source_orderrejects the DataFusion right outer join even with that ordered probe. The task fails withAll partition by columns should have an ordering. Changing only the window toPARTITION BY breturns all 12 expected rows with the same native join and no sort.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
keeps_source_ordernow accepts a right outer join whose probe declares an order. That is exactly when DataFusion keeps the join's unmatched probe rows in place, sinceHashJoinExec::executehandsright.output_ordering().is_some()to the stream. So the window's order is declared next to the join's, and your query runs. A right outer join whose probe declares nothing is still rejected. Fixed in 136e5cf.hash_join_declares_streamed_order_on_probe_inputinplanner.rsnow also checks the rule for both outer join shapes. The cache testa native window declares its order next to the order its input declaresnow runs your shape: a left outer join with a one-row broadcast table onk, andsum(v) OVER (PARTITION BY a)above it, whereais an alias ofk. A residual condition leaves unmatched rows among the matched ones of key 0, so the query would split that key if the join moved them. It checks the rows, that the window sendsa, and that no sort is planned.