Fix UnnestExec misattributing column properties on duplicated column names#23394
Open
simonvandel wants to merge 4 commits into
Open
Fix UnnestExec misattributing column properties on duplicated column names#23394simonvandel wants to merge 4 commits into
simonvandel wants to merge 4 commits into
Conversation
…ties Pure code motion: the logic that computes which non-unnested input columns map to which output columns is extracted into a helper so it can be reused. No behavior change.
Unnesting a list column yields an output column with the *same name* as the input list column, so looking up a passthrough column's output index by first-match name lookup can bind to the wrong column when a passthrough column shares its name with an unnested column (possible e.g. after a join of two tables with a common column name). Reconstruct the output layout positionally instead, and validate that the output schema lines up with the input schema.
The added validation in passthrough_columns caught the manually constructed output_schema being wrong
b32e3a8 to
e65c21b
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.
Which issue does this PR close?
I can create an issue if needed.
Rationale for this change
While working on filter pushdown for
UnnestExec, I found a problem in the existing code I wanted to re-use/repurpose.The problem was that input-output column-relationships were tracked by name. So if multiple columns have the same name, the optimizer could misattribute
PlanPropertiesto the wrong column.What changes are included in this PR?
roundtrip_unnesttest that was constructing output schema incorrectly by handAre these changes tested?
Yes, first commit demonstrates the issue, last commit fixes it.
Are there any user-facing changes?
Yes, order on query is now correct.