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
'Date32 + Interval(DayTime)' can't be evaluated because there isn't a common type to coerce the types to #2229
Describe the bug
I am trying to produce a logical plan for a SQL query that adds an interval to a date as part of the where clause and it fails with a type coercion error.
To Reproduce
Create the test file t1.csv:
d_date
1999-12-13
Run this test:
#[tokio::test]asyncfnrepro_date32_add_interval() -> Result<()>{let ctx = SessionContext::new();let schema = Schema::new(vec![Field::new("d_date",DataType::Date32,false),]);let options = CsvReadOptions::new().has_header(true).schema(&schema);
ctx.register_csv("t1","tests/t1.csv", options).await?;let df = ctx.sql("SELECT * FROM t1 WHERE d_date between cast('2002-05-30' as date) and cast('2002-05-30' as date) + INTERVAL '60 days'").await?;let plan = df.to_logical_plan();println!("{:?}", plan);Ok(())}
Expected behavior
I expect this query to run without error. Here is a similar query running in Postgres.
postgres=# select * from test where a between cast('2022-04-12' as date) and cast('2022-04-12' as date) + INTERVAL '60 days';
a
----------------------------
2022-04-13 20:29:35.879229
(1 row)
Activity
andygrove commentedon Apr 15, 2022
Fixed in #2235
alamb commentedon Apr 15, 2022
Also related #194