Skip to content

Regression in parameterized BETWEEN clause in 1.1 #15659

Open
@dylanscott

Description

What happens?

It appears that duckdb 1.1 requires explicitly casting parameters to a BETWEEN clause when it did not previously, and which it does not require if the parameters are specified (still as strings) withinin the query instead of as parameters. I could not find any mention of this change in the "Breaking SQL Changes" section of the 1.1 release post or elsewhere.

To Reproduce

import duckdb

with duckdb.connect() as conn:
    conn.execute("CALL dbgen(sf = 0.1);")
    print(
        conn.execute(
            """
            SELECT COUNT(*)
            FROM ORDERS
            WHERE O_ORDERDATE BETWEEN ? AND ?
            """,
            ["1994-01-01", "1996-01-01"],
        ).fetchone()
    )

On duckdb 1.0 the query executes correctly, but on 1.1 it raises

BinderException: Binder Error: Cannot mix values of type DATE and VARCHAR in BETWEEN clause - an explicit cast is required
LINE 4:             WHERE O_ORDERDATE BETWEEN ? AND ?

And strangely the query works on 1.1 if you inline the parameters but still specify them as strings, i.e.

SELECT COUNT(*)
FROM ORDERS
WHERE O_ORDERDATE BETWEEN '1994-01-01' AND '1996-01-01'

OS:

macOS, Linux

DuckDB Version:

1.1.3

DuckDB Client:

Python, Java

Hardware:

No response

Full Name:

Dylan Scott

Affiliation:

Hex Technologies

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions