Skip to content

CAST should not change the name of an expression #3326

@andygrove

Description

@andygrove

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

DataFusion differs from Spark and Postgres in the naming of CAST expressions. Spark and Postgres casts do not rename the column.

Spark

scala> spark.sql("select id*2, cast(id as string), name from t").show()
+--------+---+-----+
|(id * 2)| id| name|
+--------+---+-----+
|       2|  1|hello|
|       4|  2|    x|
+--------+---+-----+

Postgres

postgres=# select id*2, cast(id as varchar(12)), name from t1;
 ?column? | id | name 
----------+----+------
        2 | 1  | x

DataFusion

❯ select id*2, cast(id as varchar(12)), name from test;
+---------------------------+-----------------------+-------+
| test.id Multiply Int64(2) | CAST(test.id AS Utf8) | name  |
+---------------------------+-----------------------+-------+
| 2                         | 1                     | hello |
+---------------------------+-----------------------+-------+

Describe the solution you'd like
cast should not change expression name in results

Describe alternatives you've considered
None

Additional context
None

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions