Skip to content

CAST should not change the name of an expression #3326

Closed

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

Activity

  1. self-assigned this
    on Sep 3, 2022
  2. changed the title [-]Change physical expression name for `CAST` expressions[/-] [+]`CAST` should not change the name of an expression[/+] on Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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