Repository navigation
[SPARK-60703][SQL] Compile the source plan of a DPP broadcast value projection as an AQE subquery - #60503
Open
rekbun wants to merge 1 commit into
Open
[SPARK-60703][SQL] Compile the source plan of a DPP broadcast value projection as an AQE subquery#60503rekbun wants to merge 1 commit into
rekbun wants to merge 1 commit into
Conversation
…rojection as an AQE subquery Under AQE, `PlanAdaptiveDynamicPruningFilters.projectedBroadcast` planned the source plan of a broadcast value projection (SPARK-58265) with `QueryExecution.prepareExecutedPlan`, and went on only if it got an `AdaptiveSparkPlanExec` back. Unless `spark.sql.adaptive.forceApply` is on, `InsertAdaptiveSparkPlan` wraps a top-level plan only if it has an exchange, a distribution requirement or a subquery. The usual source plan, such as a filtered scan, has none, so the DPP filter was planned as `true` and pruned nothing. The AQE test suites force-apply AQE, which hid it. Compile the source plan with `InsertAdaptiveSparkPlan.compileSubquery`, as AQE does for the build plan that a direct broadcast reuse starts from, so that it is always wrapped.
This branch has not been deployed
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?
PlanAdaptiveDynamicPruningFilters.projectedBroadcastnow compiles the source plan of a broadcast value projection (SPARK-58265) withInsertAdaptiveSparkPlan.compileSubqueryinstead ofQueryExecution.prepareExecutedPlan. AQE already compiles the build plan of a direct broadcast reuse this way (throughSubqueryAdaptiveBroadcastExec), so the source plan is now always wrapped in anAdaptiveSparkPlanExec, as a subquery.Why are the changes needed?
projectedBroadcastgoes on only if it gets anAdaptiveSparkPlanExecback.prepareExecutedPlanrunsInsertAdaptiveSparkPlanas for a top-level query, which wraps a plan only if it has an exchange, a distribution requirement or a subquery, unlessspark.sql.adaptive.forceApplyis set. The usual source plan, such as a filtered scan, has none of these. So withspark.sql.optimizer.dynamicPartitionPruning.broadcastProjection.enabledand AQE on, the DPP filter was planned astrueand pruned nothing.The
AEOnDPP suites force-apply AQE, which hid this, andInjectRuntimeFilterSuiterecorded thetruefilter as known behavior.Does this PR introduce any user-facing change?
Yes. With the broadcast value projection enabled (off by default) and AQE on, these DPP filters now prune partitions. Results are unchanged.
How was this patch tested?
DynamicPartitionPruningSuiteBase. WithforceApplyoff, it checks the answer, the broadcast reuse, the projected subquery and the pruning values. It fails without the fix in the V1 and V2AEOnsuites.InjectRuntimeFilterSuiteto expect the projected filter under AQE too. It also fails without the fix.InjectRuntimeFilterSuite,DataSourceV2EnhancedRuntimePartitionFilterSuite, the V2 file source DPP suites and the TPC-DS and TPC-H plan stability suites.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)