Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DuckDBPyRelation.query returns relation with full SQL string as alias #468

Open

Description

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?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /