andygrove opened a new issue, #3760: URL: https://github.com/apache/arrow-datafusion/issues/3760
**Describe the bug** We hit a regression in Dask SQL after upgrading to 13.0.0-rc1 (https://github.com/dask-contrib/dask-sql/issues/844). Example query: ```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') ``` ## 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
