feat: default to sort-merge join#1651
Draft
andygrove wants to merge 6 commits intoapache:mainfrom
Draft
Conversation
Replace fragile positional `.column(1)` with schema-based `index_of("plan")`
and use `col.iter().flatten()` instead of an index loop over non-null values.
Drop the now-unneeded `Array` trait import.
DataFusion's hash join has no spill support, so each parallel task on an executor must hold the full build side in memory. Default Ballista sessions to sort-merge join (which spills) until DataFusion gains a spilling hash join. Users can opt back in with `SET datafusion.optimizer.prefer_hash_join = true`. See apache#1648
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?
Closes #1648.
Rationale for this change
DataFusion's hash join has no spill support, so the build side must fit in memory per task. Ballista executors run multiple tasks per host, so per-task build sides aggregate and OOM the executor under realistic load — for example, the integration test suite (
./dev/integration-tests.sh) does not complete on a typical machine without disabling hash joins.DataFusion sets
datafusion.optimizer.prefer_hash_join = true, which is fine for a single-node engine but a poor fit for a distributed multi-task one. This PR flips the Ballista default to sort-merge join, which spills, and leaves users a session-level knob to opt back into hash join when they know the build side fits.What changes are included in this PR?
datafusion.optimizer.prefer_hash_join = falseinsideballista_restricted_configuration(ballista/core/src/extension.rs), alongside the other soft DataFusion-default overrides. This is a soft default — users can override per session.should_support_sort_merge_joinintegration test to assert the default picksSortMergeJoinExecvia EXPLAIN, instead of relying on a result-row check that would pass under either join algorithm.should_support_hash_join_when_opted_into verify users can still getHashJoinExecafterSET datafusion.optimizer.prefer_hash_join = true.docs/source/user-guide/tuning-guide.mdunder a new "Join Strategy" subsection.Are there any user-facing changes?
Yes — behaviour change. Queries that previously planned a
HashJoinExecwill now plan aSortMergeJoinExecby default. The old behaviour is oneSETaway. Documented in the tuning guide. No public Rust API change, so noapi changelabel.