[SPARK-56204][SQL] Strip Alias wrappers from inline table row expressions in parser#55007
Open
mihailotim-db wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-56204][SQL] Strip Alias wrappers from inline table row expressions in parser#55007mihailotim-db wants to merge 1 commit intoapache:masterfrom
Alias wrappers from inline table row expressions in parser#55007mihailotim-db wants to merge 1 commit intoapache:masterfrom
Conversation
…ions in parser When the SQL parser processes `VALUES (1 AS id, 'a' AS name)`, the parenthesized expression is parsed as a `CreateNamedStruct` via `CreateStruct.apply`, which preserves `Alias` wrappers as value expressions. These `Alias` nodes then propagate into `UnresolvedInlineTable.rows` through `struct.valExprs`. The aliases are redundant for inline tables since column names are determined separately (either from the explicit table alias identifier list or generated defaults). Their presence causes issues during single-pass analysis where the `ExpressionIdAssigner` mapping is not yet initialized when processing inline table row expressions. This patch strips `Alias` wrappers from inline table row expressions in `visitInlineTable`, extracting just `alias.child`. This is safe because the alias names are already captured in the struct's name expressions and are not used for inline table column naming. Co-authored-by: Isaac
5f6f9ad to
c5fd77b
Compare
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?
When the SQL parser processes
VALUES (1 AS id, 'a' AS name), the parenthesized expression is parsed as aCreateNamedStructviaCreateStruct.apply, which preservesAliaswrappers as value expressions. TheseAliasnodes then propagate intoUnresolvedInlineTable.rowsthroughstruct.valExprs.The aliases are redundant for inline tables since column names are determined separately (either from the explicit table alias identifier list or generated defaults). Their presence causes issues during single-pass analysis where the
ExpressionIdAssignermapping is not yet initialized when processing inline table row expressions.This patch strips
Aliaswrappers from inline table row expressions invisitInlineTable, extracting justalias.child. This is safe because the alias names are already captured in the struct's name expressions and are not used for inline table column naming.Why are the changes needed?
To achieve compatibility between single-pass and fixed-point analyzers
Does this PR introduce any user-facing change?
No
How was this patch tested?
Added new golden file tests
Was this patch authored or co-authored using generative AI tooling?