[SPARK-56065][SQL] Add AQE fallback from failed broadcast joins to shuffle joins#54925
Open
sunchao wants to merge 7 commits intoapache:masterfrom
Open
[SPARK-56065][SQL] Add AQE fallback from failed broadcast joins to shuffle joins#54925sunchao wants to merge 7 commits intoapache:masterfrom
sunchao wants to merge 7 commits intoapache:masterfrom
Conversation
| buildConf("spark.sql.adaptive.broadcastJoin.fallbackToShuffle.enabled") | ||
| .doc("When true, adaptive execution retries with broadcast joins disabled if a broadcast " + | ||
| "query stage fails because it exceeds broadcast table row or size limits.") | ||
| .version("3.5.0") |
Member
There was a problem hiding this comment.
? If you want to backport this to branch-3.5, it should be 3.5.9 instead of 3.5.0.
Member
Author
There was a problem hiding this comment.
Ha thanks @dongjoon-hyun . I was able to update this. Our internal implementation is on branch-3.5 and I ported it for master
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
This looks like a good improvement for 4.2.0, doesn't it?
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.
What changes were proposed in this pull request?
This PR adds an opt-in AQE fallback path for broadcast join failures caused by broadcast table size/row limits.
When
spark.sql.adaptive.broadcastJoin.fallbackToShuffle.enabledis enabled, AQE catches qualifying broadcast stage failures and retries adaptive replanning with broadcast joins disabled, so the query can proceed with shuffle-based joins (for example SMJ/SHJ) instead of failing immediately.The change also includes safety checks to avoid repeatedly retrying the same failed broadcast relation, and test coverage in
AdaptiveQueryExecSuite.Why are the changes needed?
Today, a query can fail if a planned broadcast side exceeds runtime broadcast limits, even though a shuffle join strategy could still complete successfully.
This PR provides a controlled fallback path to improve robustness for those cases while keeping existing behavior unchanged by default.
Does this PR introduce any user-facing change?
Yes.
A new SQL config is added:
spark.sql.adaptive.broadcastJoin.fallbackToShuffle.enabled(default:false)When enabled, queries that would otherwise fail due to broadcast table row/size limits may instead continue with shuffle-based joins. When disabled, existing behavior remains unchanged.
How was this patch tested?
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala, including:Was this patch authored or co-authored using generative AI tooling?
Yes, Codex 5.3 High with a lot of harnessing