Repository navigation
perf: prefer existing co-partitioning for hash joins - #27980
Draft
2010YOUY01 wants to merge 1 commit into
Draft
2010YOUY01 wants to merge 1 commit into
2010YOUY01 wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## 2010YOUY01/join-selection-subrules #27980 +/- ##
======================================================================
+ Coverage 83.44% 83.72% +0.27%
======================================================================
Files 1061 1061
Lines 475300 507471 +32171
Branches 475300 507471 +32171
======================================================================
+ Hits 396629 424865 +28236
- Misses 54132 58101 +3969
+ Partials 24539 24505 -34
... and 121 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…or broadcast join
2010YOUY01
force-pushed
the
2010YOUY01/join-selection-copartitioning
branch
from
December 3, 2026 03:08
df55318 to
6388255
Compare
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?
This PR demonstrates how #25304 by @stuhood can be ported after the refactor in #27979, showing how the refactor makes similar changes easier to implement in the future.
Rationale for this change
A small build input currently makes an
Autohash join chooseCollectLeft, even when both inputs are already compatibly partitioned on the join keys. This unnecessarily gathers the build partitions. PreferPartitionedwhen the existing layout already satisfies the join's distribution requirements.For example, join a small dimension table with a fact table when both expose matching range partitions on the join key:
Even below the broadcast threshold, the join can use the existing partitions:
What changes are included in this PR?
Suggested reading order:
datafusion/physical-plan/src/joins/hash_join/exec/optimizations.rs—HashJoinExec::choose_partition_modechecks existing co-partitioning before the broadcast threshold, using the existing distribution compatibility check.datafusion/core/tests/physical_optimizer/join_selection.rs—PartitionCaseand the co-partitioned join tests show which layouts qualify and how this interacts with build-side swapping.datafusion/sqllogictest/test_files/repartition_subset_satisfaction.slt— updated plans show a range-partitioned join retaining its partitions and removingCoalescePartitionsExec.What is the testing strategy for this PR?
UTs
Are there any user-facing changes?
No behavior change.