fix: CometBroadcastExchangeExec should respect AQE shuffle partition coalescing#3235
Open
andygrove wants to merge 2 commits intoapache:mainfrom
Open
fix: CometBroadcastExchangeExec should respect AQE shuffle partition coalescing#3235andygrove wants to merge 2 commits intoapache:mainfrom
andygrove wants to merge 2 commits intoapache:mainfrom
Conversation
…coalescing When AQE (Adaptive Query Execution) coalesces shuffle partitions based on runtime statistics, CometBroadcastExchangeExec was bypassing this optimization by reading directly from the inner shuffle plan instead of using the coalesced partition specs from AQEShuffleReadExec. This caused broadcast exchanges to spawn many tasks (e.g., 200) even when AQE determined that only 1 task was needed due to small data volume after filtering. The fix adds proper handling for AQEShuffleReadExec wrapping CometShuffleExchangeExec: - Extract partition specs from AQEShuffleReadExec - Use CometShuffleExchangeExec.getShuffleRDD(partitionSpecs) to get the coalesced RDD - Serialize batches from the coalesced RDD for broadcasting This ensures broadcast exchanges respect AQE's partition coalescing decisions, reducing unnecessary task scheduling overhead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3235 +/- ##
============================================
+ Coverage 56.12% 60.01% +3.89%
- Complexity 976 1426 +450
============================================
Files 119 170 +51
Lines 11743 15787 +4044
Branches 2251 2611 +360
============================================
+ Hits 6591 9475 +2884
- Misses 4012 4989 +977
- Partials 1140 1323 +183 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
Should we run TPC-H benchmarks on this one? |
Member
|
In what scenarios will the CoalesceShufflePartitions rule be applied to BroadcastExchange? Could you share the spark plan? |
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
CometBroadcastExchangeExecto properly use AQE's coalesced shuffle partition specsAQEShuffleReadExecwraps aCometShuffleExchangeExec, usegetShuffleRDD(partitionSpecs)to get the coalesced RDD instead of bypassing AQEProblem
When AQE (Adaptive Query Execution) coalesces shuffle partitions based on runtime statistics,
CometBroadcastExchangeExecwas bypassing this optimization by reading directly from the inner shuffle plan. This caused broadcast exchanges to spawn many tasks (e.g., 200) even when AQE determined that only 1 task was needed due to small data volume after filtering.For example, in TPC-H Q18, after the filter
sum(l_quantity) > 313, there are only ~900 rows to broadcast. AQE correctly identifies this and coalesces 200 shuffle partitions into 1. However, Comet's broadcast exchange was ignoring this and still reading from all 200 original partitions.Solution
Added proper handling for
AQEShuffleReadExecwrappingCometShuffleExchangeExec:AQEShuffleReadExecCometShuffleExchangeExec.getShuffleRDD(partitionSpecs)to get the coalesced RDDTest plan
CometExecSuite,CometShuffleSuite)🤖 Generated with Claude Code