-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: sort file groups by statistics during sort pushdown (Sort pushdown phase 2) #21182
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
Merged
adriangb
merged 17 commits into
apache:main
from
zhuqi-lucas:feat/sort-file-groups-by-statistics
Apr 6, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4130ce4
feat: sort file groups by statistics during sort pushdown
zhuqi-lucas e2ac228
address review: remove unnecessary stats computation in reverse path,…
zhuqi-lucas 21da48f
add test: reverse path preserves file order, does not apply stats sor…
zhuqi-lucas 25938bb
restore doc comment with ASCII diagrams for get_projected_output_orde…
zhuqi-lucas 29c526b
docs: add non-overlapping exception to partition ordering diagram
zhuqi-lucas aa290d4
remove redistribute_files_across_groups_by_statistics
zhuqi-lucas b3ed744
fix: re-check ordering after statistics-based file sorting
zhuqi-lucas 5718f8a
fix: preserve fetch (LIMIT) when eliminating SortExec via Exact pushdown
zhuqi-lucas 28661d4
docs: accurate PR description and code comments for sort pushdown
zhuqi-lucas 911f0dd
docs: fix PR description and code comments to accurately describe sor…
zhuqi-lucas 35a581c
perf: increase SortPreservingMergeExec prefetch buffer from 1 to 16
zhuqi-lucas 59e99a4
fix: prevent sort elimination when files have NULLs in sort columns
zhuqi-lucas c1d0a33
fix comments
zhuqi-lucas 7cadeca
refactor: scope SPM prefetch buffer to sort elimination path only
zhuqi-lucas 63fd896
fmt
zhuqi-lucas eb1af95
refactor: replace SPM prefetch with BufferExec for sort elimination
zhuqi-lucas 790cbce
perf: increase BufferExec capacity from 8MB to 64MB for sort elimination
zhuqi-lucas 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
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.
I do think there's one more trick we could have up our sleeves: instead of only reversing row group orders we could pass the desired sort order into the opener and have it re-sort the row groups based on stats to try to match the scan's desired ordering. This might be especially effective once we have morselized scans since we could terminate after a single row group for TopK queries.
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.
Great idea! Row-group-level statistics reordering would be a natural extension of our file-level reordering but at finer granularity. Especially powerful with morselized scans where TopK could terminate after a single row group. Will track as a follow-up.
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.
If you're able to open a followup issue and link it to the PR and code that would be great!
Uh oh!
There was an error while loading. Please reload this page.
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.
@adriangb Created follow-up issue: #21317
Great idea! Row-group-level statistics reordering would be a natural extension of our file-level reordering but at finer granularity. Especially powerful with morselized scans where TopK could terminate after a single row group.