[SPARK-55654][SQL] Enable TreePattern pruning for EliminateSubqueryAliases and ResolveInlineTables#54440
Closed
yaooqinn wants to merge 1 commit intoapache:masterfrom
Closed
Conversation
…iases and ResolveInlineTables Replace AlwaysProcess.fn with pattern-based pruning in two Analyzer rules: 1. EliminateSubqueryAliases: Use _.containsPattern(SUBQUERY_ALIAS) - Skips entire plan traversal when no SubqueryAlias nodes exist - Common in resolved plans after initial resolution passes 2. ResolveInlineTables: Use _.containsPattern(INLINE_TABLE_EVAL) - Skips traversal when no UnresolvedInlineTable nodes exist - Inline tables are rare; most queries never contain them Also adds INLINE_TABLE_EVAL to UnresolvedInlineTable.nodePatterns, which was previously only on ResolvedInlineTable. Without this fix, the pruning condition could never be satisfied for unresolved inline tables, causing analysis failures for queries using VALUES clauses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b828d55 to
1cfb1c2
Compare
peter-toth
approved these changes
Feb 24, 2026
Member
Author
|
Merged to master, thank you @peter-toth |
Member
Author
|
Thank you @dongjoon-hyun |
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?
Replace
AlwaysProcess.fnwith pattern-based pruning in two Analyzer rules:EliminateSubqueryAliases: Use
_.containsPattern(SUBQUERY_ALIAS)SubqueryAliasnodes existResolveInlineTables: Use
_.containsPattern(INLINE_TABLE_EVAL)UnresolvedInlineTablenodes existAlso adds
INLINE_TABLE_EVALtoUnresolvedInlineTable.nodePatterns, which was previously only defined onResolvedInlineTable. Without this, the pruning condition forResolveInlineTablescould never be satisfied for unresolved inline tables.Both rules previously used
AlwaysProcess.fn, forcing full tree traversal on every fixedPoint iteration even when no matching nodes existed. TreePatternBits propagation enables O(1) root-level short-circuit.Why are the changes needed?
Performance optimization: avoids unnecessary full-plan traversals during analysis when the relevant node types are absent.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing tests:
AnalysisSuite,EliminateSubqueryAliasesSuite, and inline table related tests all pass.Was this patch authored or co-authored using generative AI tooling?
Yes, GitHub Copilot.