-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
Describe the bug
We hit a regression in Dask SQL after upgrading to 13.0.0-rc1 (dask-contrib/dask-sql#844).
Example query:
SELECT col_int32 FROM test
WHERE col_int32 > (
SELECT AVG(col_int32) FROM test
WHERE col_utf8 BETWEEN '2002-05-08'
AND (cast('2002-05-08' as date) + interval '5 days')
)Expected Filter
Filter: test.col_utf8 BETWEEN Utf8("2002-05-08") AND Utf8("2002-05-13")
Actual Filter
Filter: test.col_utf8 BETWEEN Utf8("2002-05-08") AND CAST(CAST(Utf8("2002-05-08") AS Date32) + IntervalDayTime("21474836480") AS Utf8)
To Reproduce
Here is a repro for the optimizer integration-test.rs:
#[test]
fn subquery_filter_with_cast() -> Result<()> {
let sql = "SELECT col_int32 FROM test \
WHERE col_int32 > (\
SELECT AVG(col_int32) FROM test \
WHERE col_utf8 BETWEEN '2002-05-08' \
AND (cast('2002-05-08' as date) + interval '5 days')\
)";
let plan = test_sql(sql)?;
let expected =
"Projection: test.col_int32\n Filter: CAST(test.col_int32 AS Float64) > __sq_1.__value\
\n CrossJoin:\n TableScan: test projection=[col_int32]\
\n Projection: AVG(test.col_int32) AS __value, alias=__sq_1\
\n Aggregate: groupBy=[[]], aggr=[[AVG(test.col_int32)]]\
\n Filter: test.col_utf8 BETWEEN Utf8(\"2002-05-08\") AND Utf8(\"2002-05-13\")\
\n TableScan: test projection=[col_int32, col_utf8]";
assert_eq!(expected, format!("{:?}", plan));
Ok(())
}Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.