Skip to content

Regression: Replacement Scans Misbehave in v1.1 #14179

@liquidcarbon

Description

@liquidcarbon

What happens?

When importing functions that use duckdb.sql("...") from modules, they don't "see" the namespace of in-memory dataframes anymore.

This was working fine in v1.0.

To Reproduce

1) create file ddb.py defining a query string with a method to run a DuckDB query:

%%writefile ddb.py
import duckdb
print(f"DuckDB v{duckdb.__version__}")
class Q_IMPORTED(str):
    def run(self):
        return duckdb.sql(self)

2) create another version of a query string locally, a sample dataframe, use imported and local query on a dataframe:

import duckdb
import pandas as pd
df = pd.DataFrame({"a": [42]})

from ddb import Q_IMPORTED

class Q_LOCAL(str):
    def run(self):
        return duckdb.sql(self)

try:
    Q("FROM df").run()
except Exception as e:
    print("Q from module", e)

Q_LOCAL("FROM df").run()
import duckdb
import pandas as pd
df = pd.DataFrame({"a": [42]})

from ddb import Q_IMPORTED

class Q_LOCAL(str):
    def run(self):
        return duckdb.sql(self)

try:
    df_from_imported = Q_IMPORTED("FROM df").run().df()
except Exception as e:
    print("Q from module", e)
    df_from_imported = None

df_from_local = Q_LOCAL("FROM df").run().df()
pd.testing.assert_frame_equal(df_from_imported, df_from_local)

output in v1.0.0

DuckDB v1.0.0

Output in v1.1.1

DuckDB v1.1.1
Q from module Catalog Error: Table with name df does not exist!
Did you mean "pg_depend"?
---------------------------------------------------------------------------
AssertionError 

OS:

Linux

DuckDB Version:

1.1

DuckDB Client:

python

Hardware:

No response

Full Name:

Alex

Affiliation:

self

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

Metadata

Assignees

No one assigned

    Labels

    Needs DocumentationUse for issues or PRs that require changes in the documentationunder review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions