What happens?
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'.
Possibly related to duckdb/duckdb#13672.
To Reproduce
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?
Did you include all relevant configuration to reproduce the issue?
What happens?
DuckDBPyRelation.queryseems to set thealiasof the returned relation to the full SQL string generating the relation. Is this intentional?This causes problems when chaining
querycalls as below:step2fails becausestep1.aliasis a SQL expression. This is surprising becausedata.aliasis a generic name such as'unnamed_relation_1a0134771ca80911'.Possibly related to duckdb/duckdb#13672.
To Reproduce
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?
Did you include all relevant configuration to reproduce the issue?