You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to project when items contain expr and Cast(expr) #4478
Describe the bug
When I want to project column and the result of its type coercion, datafusion will throw error:
❯ select a, cast(a asInt) from test0;
Plan("Projections require unique expression names but the expression \"test0.a\" at position 0 and \"CAST(test0.aAS Int32)\" at position 3 have the same name. Consider aliasing (\"AS\") one of them.")
To Reproduce
Run projection with expression and its cast-wrapped expression.
changed the title [-]Failed to project when projection contains expr and Cast(expr)[/-][+]Failed to project when items contain expr and Cast(expr)[/+]on Dec 2, 2022
Activity
[-]Failed to project when projection contains expr and Cast(expr)[/-][+]Failed to project when items contain expr and Cast(expr)[/+]HaoYang670 commentedon Dec 2, 2022
This is because the
castexpression is ignored in the column name, which is an expected behaviour, I guess.ygf11 commentedon Dec 2, 2022
Yes, cast expression is ignored in the column name.
I think the other reason is our projection does not support duplicated items which seems PostgreSQL and spark both support.
spark
PostgreSQL
datafusion
mingmwang commentedon Dec 7, 2022
Why it is the expected behavior ?
mingmwang commentedon Dec 7, 2022
I think SparkSQL does not have a consistent behavior.
See example below:
SparkSQL 3.x Thrift Server JDBC
Result:
+-----+-----+-------------------------------------------------------------------+
| t1_id | t1_id | (CAST(t1_id AS DECIMAL(10,0)) + CAST(t1_id AS DECIMAL(10,0))) |
+-----+-----+-------------------------------------------------------------------+
+-----+-----+-------------------------------------------------------------------+