diff --git a/duckdb_engine/tests/test_basic.py b/duckdb_engine/tests/test_basic.py index 9b7e825b..b474de0f 100644 --- a/duckdb_engine/tests/test_basic.py +++ b/duckdb_engine/tests/test_basic.py @@ -22,6 +22,7 @@ String, Table, create_engine, + func, inspect, select, text, @@ -426,3 +427,23 @@ def test_params(engine: Engine) -> None: s = text("SELECT :x") with engine.connect() as conn: assert ("m",) == conn.execute(s, {"x": "m"}).fetchone() + + +def test_361(engine: Engine) -> None: + with engine.connect() as conn: + conn.execute(text("create table test (dt date);")) + conn.execute(text("insert into test values ('2022-01-01');")) + + metadata = MetaData() + metadata.reflect(bind=conn) + test = metadata.tables["test"] + part = "year" + date_part = func.date_part(part, test.c.dt) + + stmt = ( + select(date_part) + .select_from(test) + .group_by(date_part) + .compile(dialect=engine.dialect, compile_kwargs={"literal_binds": True}) + ) + conn.execute(stmt).fetchall()