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
DuckDBPyRelation.query returns relation with full SQL string as alias #468
DuckDBPyRelation.query seems to set the alias of the returned relation to the full SQL string generating the relation. Is this intentional?
This causes problems when chaining query calls as below: step2 fails because step1.alias is a SQL expression. This is surprising because data.alias is a generic name such as 'unnamed_relation_1a0134771ca80911'.
import duckdb
con = duckdb.connect()
con.execute("CREATE TABLE raw (year INT, facility VARCHAR, value DOUBLE)")
con.execute("INSERT INTO raw VALUES (2020, 'F001', 1.0), (2021, 'F001', 2.0)")
data = con.sql("SELECT * FROM raw")
step1 = data.query(data.alias, f"SELECT *, value * 2 AS doubled FROM {data.alias}")
step2 = data.query(step1.alias, f"SELECT *, doubled + 1 AS incremented FROM {step1.alias}") # This fails with _duckdb.ParserException: Parser Error: syntax error at or near "SELECT"
OS:
OSX
DuckDB Package Version:
1.5.1
Python Version:
3.14
Full Name:
Leonard Stimpfle
Affiliation:
Ghent University
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have not tested with any build
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 to reproduce the issue?
I think this is caused by inadvertently reversed arguments to QueryRelation. See details in #521. @evertlammerts please let me know if there are any issues with the PR
Activity
leostimpfle commentedon Jun 30, 2026
I think this is caused by inadvertently reversed arguments to
QueryRelation. See details in #521. @evertlammerts please let me know if there are any issues with the PRClose #468
Fix alias of `DuckDBPyRelation.query` (#521)
Close #468
Fix alias of `DuckDBPyRelation.query` (closes #468) (#524)
evertlammerts commentedon Jul 1, 2026
Thanks!