Repository navigation
[branch-56] feat/perf: derive SortMergeJoin sort options from input ordering and allow SMJ for a single partition (backport #26261) - #27850
Draft
xudong963 wants to merge 4 commits into
Conversation
This was referenced Nov 30, 2026
Merged
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## branch-56 #27850 +/- ##
=============================================
- Coverage 83.31% 83.31% -0.01%
=============================================
Files 1171 1171
Lines 477062 477103 +41
Branches 477062 477103 +41
=============================================
+ Hits 397480 397511 +31
- Misses 55523 55526 +3
- Partials 24059 24066 +7
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
xudong963
added a commit
that referenced
this pull request
Dec 1, 2026
…imestamps at minute and finer granularities (backport #27547) (#27848) ## Which issue does this PR close? - Backport of #27547 to `branch-56`, for #24463, which lists it as a regression in 56. - Part of #25464. ## Rationale for this change #25409, new in 56, stopped `date_trunc` from propagating its input ordering for every timezone-aware timestamp. So since 56.0.0, sorting or grouping by `date_trunc('minute', ts)` over input ordered on `ts` adds a sort and loses clustered aggregation, where 55 did not. #27547 restores the ordering for `minute` and finer granularities, where truncation is arithmetic on the epoch value and cannot reorder values. ## What changes are included in this PR? A clean cherry-pick of #27547 (`477c7b9`) with `-x`. No conflicts. ## What is the testing strategy for this PR? The `date_trunc` unit tests and `datetime/timestamps.slt` pass on this branch. Applied on `branch-56` together with the other backports, #27846 (#27021), #27847 (#27150), #27849 (#27732) and #27850 (#26261), the full sqllogictest suite, `cargo fmt --check` and clippy on the touched crates also pass. ## Are there any user-facing changes? Plans only: no `SortExec`, and clustered aggregation, for `date_trunc` at `minute` and finer over ordered timezone-aware input. Results are unchanged. No API changes.
alamb
pushed a commit
that referenced
this pull request
Dec 1, 2026
…ue` (backport #27150) (#27847) ## Which issue does this PR close? - Backport of #27150 to `branch-56`, for #24463. - Closes #27149 for the 56 line. ## Rationale for this change Without an `ORDER BY`, `first_value` has no `GroupsAccumulator`, so grouped aggregation keeps one boxed accumulator per group. Every `DISTINCT ON` without `ORDER BY` plans unordered `first_value`. #27150 measured 6x to 18x faster queries and up to 2.7x lower peak memory on ClickBench queries with 17.6M groups. ## What changes are included in this PR? A clean cherry-pick of #27150 (`26de352`) with `-x`. No conflicts. ## What is the testing strategy for this PR? The `first_last` unit tests from #27150 pass on this branch, as do `aggregate*.slt`, `group_by.slt` and `window*.slt`. Applied on `branch-56` together with the other backports, #27846 (#27021), #27848 (#27547), #27849 (#27732) and #27850 (#26261), the full sqllogictest suite, `cargo fmt --check` and clippy on the touched crates also pass. ## Are there any user-facing changes? No API changes. `first_value` without `ORDER BY`, including `DISTINCT ON`, is faster. The intermediate state layout is unchanged (`[first_value, is_set]`), so partial and final aggregation see the same schema as before. Co-authored-by: Rohan Krishnaswamy <47869999+rkrishn7@users.noreply.github.com>
xudong963
added a commit
that referenced
this pull request
Dec 2, 2026
…#27021) (#27846) ## Which issue does this PR close? - Backport of #27021 to `branch-56`, for #24463. - Closes #27020 for the 56 line. ## Rationale for this change arrow-csv maps CSV columns by position. When files in one table have different column layouts, values land in the wrong columns or parsing fails. #27021 adds an opt-in `match_columns_by_header` option that maps each file's columns to the table schema by header name. Users on 56 who read CSV files whose layout changed over time need this before 57. ## What changes are included in this PR? A cherry-pick of #27021 (`3f837ad`) with `-x`. The only conflict was in `docs/source/library-user-guide/upgrading/56.0.0.md`: on `main` that file also has a section from an unrelated PR (`CreateFunction` field types), so I kept only the `match_columns_by_header` section. ## What is the testing strategy for this PR? The tests from #27021 pass on this branch: the `datafusion-datasource-csv` unit tests, the CSV tests in `core_integration`, the proto round-trip tests, `csv_files.slt` and `information_schema.slt`. Applied on `branch-56` together with the other backports, #27847 (#27150), #27848 (#27547), #27849 (#27732) and #27850 (#26261), the full sqllogictest suite, `cargo fmt --check` and clippy on the touched crates also pass. ## Are there any user-facing changes? - New opt-in `format.match_columns_by_header` option, default `false`. Existing reads are unchanged. - API: `CsvOptions` and `CsvReadOptions` gain a public `match_columns_by_header` field. Neither struct is `#[non_exhaustive]`, so code that builds them with an exhaustive struct literal stops compiling until it adds the field or uses `..Default::default()`. This is noted in the 56.0.0 upgrade guide. Please weigh this for a minor release. - Proto: `CsvOptions` (field 23) and `CsvScanExecNode` (field 10) gain the same field, with the same field numbers as `main`. Co-authored-by: Wyatt Herkamp <wyatt.herkamp@massive.com> Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
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?
branch-56, for Release DataFusion56.1.0(minor/patch) Release (Dec 2026) #24463.#26261 has not merged to
mainyet, so this stays a draft until it does. Once it merges, I will replace these commits with the merge commit.Rationale for this change
With
prefer_hash_join = false, the planner hardcodesASC NULLS FIRSTfor every sort-merge join key. Inputs already sortedDESC,NULLS LAST, or with different options per key get sorted again. Withtarget_partitions = 1,prefer_hash_join = falseis ignored and a hash join is planned. #26261 fixes both.What changes are included in this PR?
The four commits of #26261 (head
f9bae8c), cherry-picked with-x.The conflicts were all in
physical_planner.rs.mainhas a null-aware sort-merge join path for single-keyLeftAntijoins thatbranch-56does not have. I kept thebranch-56structure without it and applied only the parts of #26261: the key order and sort option derivation (sort_merge_join_keys) and the new SMJ condition. I adjusted the nearby comments, which onmaindescribe the null-aware path.What is the testing strategy for this PR?
The
physical_plannerunit tests,sort_merge_join*.slt(including the newsort_merge_join_sort_options.sltand the newtarget_partitions = 1cases),joins.sltandsubquery.sltpass on this branch.Applied on
branch-56together with the other backports, #27846 (#27021), #27847 (#27150), #27848 (#27547) and #27849 (#27732), the full sqllogictest suite,cargo fmt --checkand clippy on the touched crates also pass.Are there any user-facing changes?
Plans change only with
prefer_hash_join = false. FewerSortExecs are added underSortMergeJoinExecwhen the inputs are already sorted on the join keys. Withtarget_partitions = 1, a sort-merge join is planned instead of a hash join. Results are unchanged. No API changes.