[SPARK-59146][SQL] Retain qualified access to source columns after pipe SET - #58987
Open
joelrobin18 wants to merge 10 commits into
Open
joelrobin18 wants to merge 10 commits into
joelrobin18 wants to merge 10 commits into
Conversation
This branch has not been deployed
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?
This PR preserves the qualified input row of each SQL pipe
SETassignment. It adds a transparentPipeSetInputlogical-plan marker whose original qualified output is exposed as qualified-access-only metadata and materialized only when a parent expression needs it.The fixed-point and single-pass analyzers both understand the marker. Occurrence-aware output merging preserves source order and repeated attributes, while metadata pruning keeps retained columns out of the visible
SETschema and unqualified stars. The marker is removed after analysis.The change also handles Spark Connect plan-ID resolution, qualified-star expansion, metadata-column overlap, and struct-field/table-alias name collisions without changing ordinary metadata or USING-join behavior.
Why are the changes needed?
Pipe
SETreplaces an assigned column in its projection. The original attribute is consequently dropped, even though Spark documents that table aliases continue to refer to original row values after an assignment. For example,t.acurrently fails to resolve here:The assigned value must remain available as
a, whilet.amust resolve to the original value.Does this PR introduce any user-facing change?
Yes. Qualified references to columns affected by pipe
SETnow resolve to the original input value instead of failing analysis. In the example above, the result is(2, 1). The visibleSETschema and unqualifiedSELECT *output are unchanged.How was this patch tested?
Added Catalyst and SQL regression coverage for scalar qualified access, qualified and unqualified stars, sequential assignments, repeated source attributes, intervening operators, USING joins, struct/table-alias collisions, metadata columns, plan IDs, and fixed-point/single-pass analyzer parity.
The following checks passed:
git diff --check, changed-source line-length checks, and non-ASCII checks also passed.Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)