[SPARK-54593][SQL] Expand DPP for LogicalRelation and LogicalRDD #53324
+185
−0
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?
This PR extends Dynamic Partition Pruning (DPP) support to include
LocalRelationandLogicalRDDas selective predicates in thePartitionPruningoptimizer rule.hasSelectivePredicate()to treatLocalRelationandLogicalRDDas selective predicatescalculatePlanOverhead()to handleLocalRelationandLogicalRDDwith statistics as cached data sources with zero overheadisLogicalRDDWithStats()to distinguish LogicalRDDs with materialized statistics from those with default estimateshttps://issues.apache.org/jira/browse/SPARK-54593
Why are the changes needed?
Expanding from previous commit and Jira ticket: #53263 and https://issues.apache.org/jira/browse/SPARK-54554
LocalRelation(from VALUES clauses) andLogicalRDD(from checkpoint or createDataFrame with statistics) represent small, materialized datasets that are ideal candidates for DPP optimization. However, the current implementation only recognizesFilter, but not these node types as selective predicates, missing optimization opportunities in broadcast joins.By enabling DPP for these cases, queries joining partitioned tables with small in-memory datasets can benefit from runtime partition pruning, reducing data scanning and improving query performance.
Does this PR introduce any user-facing change?
No. This is a pure optimizer enhancement. Users may observe improved query performance for joins between partitioned tables and small datasets created via VALUES clauses or checkpoint operations, but there are no API or behavioral changes.
How was this patch tested?
Added 5 comprehensive tests to
DynamicPartitionPruningSuite:All tests explicitly verify
DynamicPruningSubqueryappears (or doesn't appear) in the optimized logical plan and use exact result verification withcheckAnswer. All existing tests continue to pass.Was this patch authored or co-authored using generative AI tooling?
No