rekbun opened a new pull request, #60503:
URL: https://github.com/apache/spark/pull/60503

   ### What changes were proposed in this pull request?
   
   `PlanAdaptiveDynamicPruningFilters.projectedBroadcast` now compiles the 
source plan of a broadcast value projection (SPARK-58265) with 
`InsertAdaptiveSparkPlan.compileSubquery` instead of 
`QueryExecution.prepareExecutedPlan`. AQE already compiles the build plan of a 
direct broadcast reuse this way (through `SubqueryAdaptiveBroadcastExec`), so 
the source plan is now always wrapped in an `AdaptiveSparkPlanExec`, as a 
subquery.
   
   ### Why are the changes needed?
   
   `projectedBroadcast` goes on only if it gets an `AdaptiveSparkPlanExec` 
back. `prepareExecutedPlan` runs `InsertAdaptiveSparkPlan` as for a top-level 
query, which wraps a plan only if it has an exchange, a distribution 
requirement or a subquery, unless `spark.sql.adaptive.forceApply` is set. The 
usual source plan, such as a filtered scan, has none of these. So with 
`spark.sql.optimizer.dynamicPartitionPruning.broadcastProjection.enabled` and 
AQE on, the DPP filter was planned as `true` and pruned nothing.
   
   The `AEOn` DPP suites force-apply AQE, which hid this, and 
`InjectRuntimeFilterSuite` recorded the `true` filter 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?
   
   - New test "SPARK-60703: project broadcast value rows when AQE is not 
force-applied" in `DynamicPartitionPruningSuiteBase`. With `forceApply` off, it 
checks the answer, the broadcast reuse, the projected subquery and the pruning 
values. It fails without the fix in the V1 and V2 `AEOn` suites.
   - Updated the SPARK-60702 test in `InjectRuntimeFilterSuite` to expect the 
projected filter under AQE too. It also fails without the fix.
   - Ran the DPP suites (V1, V2, AQE on and off, Hive), 
`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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to