You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimizer regressions in unwrap_cast_in_comparison #3690
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]fnunsigned_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]fncase_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.
#[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 = "Projection: CASE WHEN CAST(#test.col_int32 AS Int64) > Int64(0) THEN Int64(1) ELSE Int64(0) END\
\n TableScan: test projection=[col_int32]";
assert_eq!(expected, format!("{:?}", plan));
Ok(())
}
In the rule of unwrap_cast_in_comparison, we can't find the filed type of 'test.col_int32' for the projection plan.
Activity
liukun4515 commentedon Oct 4, 2022
@andygrove
Does the failed about the
case whencaused by this issue?I will check them.
liukun4515 commentedon Oct 4, 2022
For the
case whencaseIn the rule of
unwrap_cast_in_comparison, we can't find the filed type of'test.col_int32'for theprojectionplan.Because the schema for the projection is:
and the schema of table scan is:
I am confused about the difference between these two plan.
Why the schema for the projection plan is the output expr for the plan?
@alamb @andygrove
I think the schema should only contain the fields from the table, but I find the output expr for the projection plan.
liukun4515 commentedon Oct 4, 2022
I think the schema for the logical plan is very important, and we can extract and generate any information from the basic schema.
For example:
sql:
The plan should be