Skip to content

[SPARK-56204][SQL] Strip Alias wrappers from inline table row expressions in parser#55007

Open
mihailotim-db wants to merge 1 commit intoapache:masterfrom
mihailotim-db:strip-inline-table-aliases
Open

[SPARK-56204][SQL] Strip Alias wrappers from inline table row expressions in parser#55007
mihailotim-db wants to merge 1 commit intoapache:masterfrom
mihailotim-db:strip-inline-table-aliases

Conversation

@mihailotim-db
Copy link
Contributor

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 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.

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?

@mihailotim-db mihailotim-db marked this pull request as draft March 25, 2026 17:06
@mihailotim-db mihailotim-db marked this pull request as ready for review March 25, 2026 17:06
…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
@mihailotim-db mihailotim-db force-pushed the strip-inline-table-aliases branch from 5f6f9ad to c5fd77b Compare March 25, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant