-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Union columns with different types #3467
Comments
@alamb I am going to fix this problem. Is it fine if I will implement autocast for numeric types in UnionExec? Or you see better way? |
I think the appropriate code to call would be "coerce" (as in the types of the union should be coerced to a common type). There is already code to do that for other similar operations (like |
@gandronchik But now we are doing the migration the type coercion to logical phase #3388 |
@liukun4515 Got it. I will implement it in logical plan then |
you can refer this pr #3472 |
Why did you decide to do coercion in optimizators? At least in case with union I think it is better to do it directly in union building function
|
I highly agree with @gandronchik that this should be done in the planner instead of the type coerce optimizer. |
Yes, agree with you. The type coercion should be done in the analyse phase, because of the codebase we can do this in the right place. We do the type coercion in the physical phase when creating the physical expr. cc @alamb @andygrove |
Describe the bug
You can union columns with different types. And it crashes if we order by this column
To Reproduce
it is just strange behavior:
select 1 a union all select 'a';
it should work, however since 1 is an integer and 1.1 is a decimal, it crashes:
select 1 a union all select 1.1 order by 1;
Additional context
Physical Sort Node does concat and it crashes. Looks like Union node has to autocast numeric types and returns error for rest types;
The text was updated successfully, but these errors were encountered: