`DuckDBPyRelation.query()`: reusing a virtual table name silently changes the result of an existing relation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia dal punto di ingresso DuckDBPyRelation.query() ed esegui la riproduzione Python fornita sulle versioni del pacchetto elencate. Traccia quando viene risolto il nome della tabella virtuale, quindi aggiungi un test di regressione per il comportamento scelto: una relazione esistente non deve cambiare silenziosamente dopo che il nome viene riutilizzato, oppure il contratto di risoluzione tardiva deve essere documentato nella documentazione dell’API relazionale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens?
rel.query(virtual_table_name, sql) returns a lazy relation that re-resolves virtual_table_name through the connection's catalog on every execution. Registering the same name again from a different relation therefore changes what an already-constructed relation returns, with no error, even after that relation has been executed once.
Why it matters
Wrong data rather than an error. For a library this rules out any fixed name, so we generate a unique random name per call, which then accumulates.
What I would expect
One of:
- the derived relation binds the virtual table once, at construction, so it is unaffected by later registrations; or
- re-registering a name that a live relation depends on raises; or
- if this is intended, a note on the relational API docs saying that the name is resolved late and must not be reused.
To Reproduce
import duckdb
con = duckdb.connect()
a = con.sql("select 1 as a")
b = con.sql("select 999 as a")
first = a.query("v", "select a from v")
print(first.fetchall()) # [(1,)]
second = b.query("v", "select a from v") # same name, unrelated relation
print(second.fetchall()) # [(999,)]
print(first.fetchall()) # [(999,)] <- silently changed
OS:
Darwin, arm64
DuckDB Package Version:
1.1.0, 1.2.2 and 1.5.5.
Python Version:
3.12
Full Name:
Francesco Bruzzesi
Affiliation:
narwhals-dev
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?
Not applicable - the reproduction does not require a data set
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
- Lingua principale
- Python
- Stelle
- 186
- Fork
- 113
- Merge medio
- 20h 58m
- PR unite (30g)
- 11
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di duckdb/duckdb-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
duckdb/duckdb-python#627 ·
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
duckdb/duckdb-python#576 · 3 commenti ·
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
duckdb/duckdb-python#534 ·
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
duckdb/duckdb-python#386 ·
-
needs triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
duckdb/duckdb-python#622 ·
Tutte le issue di duckdb/duckdb-python
Issue simili
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
apache/cloudstack#14222 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100