fix: CometBroadcastExchangeExec should respect AQE shuffle partition coalescing #3235
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