-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix df union all bug #2108
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
fix df union all bug #2108
Conversation
|
cc @xudong963 @alamb PTAL |
Ted-Jiang
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 @WinkerDu ❤️! would you mind fix the conflicts?
OK, ASAP |
| /// Check to see if df field data types in df schema matches with input df schema | ||
| pub fn matches_arrow_schema_with_type(&self, df_schema: &DFSchema) -> bool { | ||
| self.fields | ||
| .iter() |
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.
in postgresql union support type cast like below
postgres=# select '1.2' as a union select 2.3 as b union select 3 as b ;
a
-----
2.3
3
1.2
(3 rows)
postgres=# \gdesc
Column | Type
--------+---------
a | numeric
(1 row)
Maybe we can open a ticket support this ?
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.
@Ted-Jiang Agree with that.
Maybe we can solve Alias issue first, than open a new issue to fully discuss data type compatible cast?
ce72ff2 to
e50b016
Compare
|
cc @xudong963 @Ted-Jiang |
datafusion/common/src/dfschema.rs
Outdated
| .iter() | ||
| .zip(arrow_schema.fields().iter()) | ||
| .all(|(l_field, r_field)| { | ||
| can_cast_types(r_field.data_type(), l_field.data_type()) |
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.
If this would return a Result<()> we could return a more specific error of the type mismatch here (and pass it to the user).
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.
@Dandandan OK, I'll fix it.
|
@Dandandan PTAL, thanks |
|
cc @alamb @yjshen @xudong963 |
yjshen
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.
I'm a little bit conservative on the general auto alias columns behavior. But since this work limits such aliases to only the union case, I think it's cool to go.
Thanks again @WinkerDu!
|
Thank you for sticking with this @WinkerDu -- 👍 and thank you @Ted-Jiang for the assist |
|
@WinkerDu Thank you! Sorry for not checking in time. I had some personal affairs recently. |
Which issue does this PR close?
Closes #1818.
Rationale for this change
when union different some constants,
UNION ALL schemas are expected to be the samewould raise, likeThis pr fix it.
What changes are included in this PR?
AliasandColumninProjectionunderUnion, other expressions should be aliased with column index likecolumn0Are there any user-facing changes?
No.