feat: sort file groups by statistics during sort pushdown#20304
Draft
adriangb wants to merge 6 commits intoapache:mainfrom
Draft
feat: sort file groups by statistics during sort pushdown#20304adriangb wants to merge 6 commits intoapache:mainfrom
adriangb wants to merge 6 commits intoapache:mainfrom
Conversation
d804a24 to
d948f90
Compare
Contributor
Author
|
I'm going to wait to sequence this after #20329. I think this also fixes the bug but I'd rather do bugfix and feature independently. |
Add statistics-based file reordering within file groups during sort pushdown. When pushing sort requirements down to DataSourceExec, files within each group are now sorted by their min/max statistics to better align with the requested ordering. Non-overlapping files with guaranteed within-file ordering enable complete sort elimination (Exact), while overlapping files get best-effort reordering (Inexact) with SortExec retained for correctness. Key changes: - FileScanConfig::rebuild_with_source sorts files by statistics - FileScanConfig::sort_files_within_groups_by_statistics detects non-overlapping file ranges for sort elimination - ParquetSource::try_pushdown_sort returns Exact when natural ordering matches the request, enabling sort elimination - Add SLT integration tests (Tests 4-7) covering non-overlapping, overlapping, reverse scan, and multi-group scenarios Related to apache#19724 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace old-style format arguments with inlined variable syntax to fix clippy warnings (uninlined_format_args). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…lapping check Replace `all_non_overlapping = true` default with a counter that requires positive confirmation from every group. If any group is skipped without confirmation (e.g. due to a future code path that continues early), the count won't match and we conservatively keep the SortExec rather than risk eliminating it incorrectly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the `(Vec<FileGroup>, bool, bool)` return type of `sort_files_within_groups_by_statistics` with a named struct `SortedFileGroups` for clarity at call sites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… sorting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
run benchmark clickbench_partitioned |
4 tasks
|
🤖 |
|
🤖: Benchmark completed Details
|
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.
Summary
Exact), theSortExecis completely eliminatedSortExecretained for correctness (Inexact)ParquetSource::try_pushdown_sortnow returnsExactwhen the file's natural ordering already satisfies the request, enabling sort elimination for the same-direction caseRelated to #19724
Test plan
cargo test -p datafusion-sqllogictest --test sqllogictests -- sort_pushdownpassescargo test -p datafusion-sqllogictest --test sqllogictests -- parquet_sorted_statisticspasses🤖 Generated with Claude Code