Skip to content

regression in casting between 35 and 36.  #9951

@universalmind303

Description

@universalmind303

Describe the bug

Previously (df 35) if you did an invalid cast, it would fail during logical planning. However, in datafusion 36, it does not fail during planning as expected.

A way to visualize this is via explain. It'll show an empty result set if the planning errored out.

To Reproduce

A simple example of an invalid cast, casting string to int;

Datafusion 35

DataFusion CLI v35.0.0
❯ explain select CAST('test' as int);
0 rows in set. Query took 0.016 seconds.

Datafusion 36

DataFusion CLI v36.0.0
❯ explain select CAST('test' as int);
+---------------+------------------------------------------------------------+
| plan_type     | plan                                                       |
+---------------+------------------------------------------------------------+
| logical_plan  | Projection: CAST(Utf8("test") AS Int32)                    |
|               |   EmptyRelation                                            |
| physical_plan | ProjectionExec: expr=[CAST(test AS Int32) as Utf8("test")] |
|               |   PlaceholderRowExec                                       |
|               |                                                            |
+---------------+------------------------------------------------------------+
2 rows in set. Query took 0.008 seconds.

### Expected behavior

in this example, i'd expect the cast to fail during planning as it did in 35

### Additional context

datafusion 35 will fail at 'simplify_expressions`

```sql
❯ select CAST('test' as int);
Optimizer rule 'simplify_expressions' failed
caused by
Arrow error: Cast error: Cannot cast string 'test' to value of Int32 type

while 36 does not seem to specify anything about optimization, and seems to fail at execution instead of planning

select CAST('test' as int);
Arrow error: Cast error: Cannot cast string 'test' to value of Int32 type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions