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

   ### What changes were proposed in this pull request?
   
   Without AQE, `PlanDynamicPruningFilters` now reuses a broadcast for a DPP 
filter only if a broadcast hash join that is not a null-aware anti join 
broadcasts the same plan with the same `HashedRelationBroadcastMode`. 
`PlanAdaptiveDynamicPruningFilters` already requires this, and so does the 
broadcast value projection (SPARK-58265) on this path. Before, the direct reuse 
checked only that the plans had the same result.
   
   `InjectRuntimeFilter.broadcastablePlans` now leaves out a null-aware anti 
join's build side with AQE off too, since physical planning no longer counts it 
as reusable. That key can then get a bloom filter instead.
   
   ### Why are the changes needed?
   
   When the reuse check passed, the filter built its own 
`BroadcastExchangeExec`, keyed by the filter's build keys. If the join 
broadcast the same plan on other keys, or was a null-aware anti join, the two 
exchanges had different modes, so `ReuseExchangeAndSubquery` could not share 
them and the build plan ran and was broadcast twice. For example, in a union 
whose other branch broadcasts the dimension plan on `s.store_id * 10`, the plan 
had two broadcast exchanges of the same build plan.
   
   That goes against 
`spark.sql.optimizer.dynamicPartitionPruning.reuseBroadcastOnly`, under which a 
DPP filter should only reuse an existing broadcast, and it differs from AQE, 
which plans such a filter as `true`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No change in results. Without AQE, a DPP filter that only reuses broadcasts 
(`onlyInBroadcast`) and finds no broadcast with the same mode is now planned as 
`true`, as with AQE, and the build plan is broadcast once. Such a filter used 
to prune at the cost of a second broadcast.
   
   ### How was this patch tested?
   
   - Turned around the existing unit test that expected direct reuse across 
modes and for null-aware joins, and added a same-mode control.
   - New end-to-end test: the union above plans one broadcast exchange.
   - Updated the null-aware anti join test in `InjectRuntimeFilterSuite`.
   - All three fail without the fix.
   - Ran the DPP suites (V1, V2, AQE on and off, Hive), 
`InjectRuntimeFilterSuite`, the V2 file source DPP suites and the TPC-DS and 
TPC-H plan stability suites, whose golden files are unchanged.
   
   ### 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