Repository navigation
fix: alias surviving union inputs after an empty input is removed - #27612
Open
Adam-Alani wants to merge 1 commit into
Open
Adam-Alani wants to merge 1 commit into
Adam-Alani wants to merge 1 commit into
Conversation
propagate_empty_relation kept the removed input's field names when two or more union inputs survived. Physical planning then asserted that each input's column name matched that projection.
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?
Rationale for this change
SELECT a FROM t WHERE false UNION ALL SELECT b FROM s UNION ALL SELECT c FROM ufails while creating a physical plan:propagate_empty_relationdrops the empty input and keeps the union schema, whose names came from that input. #26557 maps the remaining input by position when it is the only one left. When two or more inputs survive, the union is rebuilt with those names and the other inputs are left unchanged.What changes are included in this PR?
When an empty union input is removed and more than one input remains, each surviving input whose field names differ from the union schema is wrapped in a projection that aliases its columns by position. Inputs that already use those names are left as they are. The single-remaining-input path uses the same projection helper.
What is the testing strategy for this PR?
propagate_union_children_different_schemanow expects the positional aliases.propagate_union_multiple_remaining_inputs_with_other_namescovers two surviving inputs with different names.union.sltexecutes theUNION ALLandUNIONforms.cargo test -p datafusion-optimizer --lib propagate_unionpasses locally.Are there any user-facing changes?
Queries that previously failed to plan now return rows. Plans whose remaining inputs already share the union's field names are unchanged.