Skip to content

Types are not checked when building case expression #4660

@HaoYang670

Description

@HaoYang670

Describe the bug
A clear and concise description of what the bug is.
The type of case expression is not checked when building the plan.

To Reproduce

DataFusion CLI v15.0.0
❯ create table t as select 2 as a;
0 rows in set. Query took 0.013 seconds.
❯ select case
    when a = 1 then true
    when a = 2 then 'abc'
    else 123
  end  
from t;
Internal("The type of Boolean AND Utf8 of binary physical should be same")

Expected behavior
We should return a DatafusionError::Plan(...), instead of an Internal error.

Additional context
The CaseBuilder does some type checking, but it seems that it is bypassed.
https://github.com/apache/arrow-datafusion/blob/c2f199adbec8b650de5668c97675f8a757607df8/datafusion/expr/src/conditional_expressions.rs#L100-L110

  • Check when expr
  • Check then and else

Metadata

Metadata

Assignees

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