-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Ensure columns are casted to the correct names with Unions #20146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Projection: test.col_int32 AS id | ||
| TableScan: test projection=[col_int32] | ||
| Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32) AS id | ||
| Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are ok, the alias had been introduced by #19019 but it was not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't needed because the outer query doesn't use id?
dd-annarose
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nuno-faria -- this looks good to me. Given all the tests pass I think this one is good to go, though it is strange to me 🤔 I wonder if this is something specific to unions
| Ok(expr.cast_to(new_type, src_schema)?.alias(name)) | ||
| match expr { | ||
| // maintain the original name when casting a column | ||
| Expr::Column(ref column) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some context about why we maintain the original name only for columns?
| Projection: test.col_int32 AS id | ||
| TableScan: test projection=[col_int32] | ||
| Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32) AS id | ||
| Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't needed because the outer query doesn't use id?
Which issue does this PR close?
Rationale for this change
When aliasing a cast, use the original name to prevent duplicate column names errors.
What changes are included in this PR?
coerce_exprs_for_schemato use the correct name.Are these changes tested?
Yes.
Are there any user-facing changes?
No.