Skip to content

Optimizer regressions in unwrap_cast_in_comparison #3690

@andygrove

Description

@andygrove

Describe the bug
I am testing the latest code from master with some Dask SQL queries and seeing some new regressions that were caused by #3662.

To Reproduce

Error casting to unsigned types

#[test]
fn unsigned_target_type() -> Result<()> {
    let sql = "SELECT * FROM test WHERE col_uint32 > 0";
    let plan = test_sql(sql)?;
    let expected = "TBD";
    assert_eq!(expected, format!("{:?}", plan));
    Ok(())
}
Error: Internal("Optimizer rule 'unwrap_cast_in_comparison' failed due to unexpected error: Internal error: Error target data type UInt32. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker")

CASE WHEN regression

#[test]
fn case_when() -> Result<()> {
    let sql = "SELECT CASE WHEN col_int32 > 0 THEN 1 ELSE 0 END FROM test";
    let plan = test_sql(sql)?;
    let expected = "TBD";
    assert_eq!(expected, format!("{:?}", plan));
    Ok(())
}
Error: Internal("Optimizer rule 'unwrap_cast_in_comparison' failed due to unexpected error: Schema error: No field named 'test.col_int32'. Valid fields are 'CASE WHEN test.col_int32 > Int64(0) THEN Int64(1) ELSE Int64(0) END'.")

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

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