Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Date32 + Interval(DayTime)' can't be evaluated because there isn't a common type to coerce the types to #2229

Closed
Tracked by #474
andygrove opened this issue Apr 14, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@andygrove
Copy link
Member

andygrove commented Apr 14, 2022

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]
async fn repro_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)

Additional context
None

@andygrove
Copy link
Member Author

Fixed in #2235

@alamb
Copy link
Contributor

alamb commented Apr 15, 2022

Also related #194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants