Join behavior inconsistency with duckdb 2.0
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Start with the relation API implementation reached through duckdb/_relation.py and reproduce the two join forms with the provided registered pandas DataFrames. Trace how equality-expression joins alter relation binding or table qualification, and add a regression test showing that table_one, table_two, and table_three remain selectable. The issue is done when the equality-expression query selects from all three tables without a BinderException.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What happens?
When I join three tables with condition = 'column', I can select from all three joined tables
When I join with a condition table['column'] == table['column'], I can't select from all three tables using their table names
To Reproduce
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import duckdb
import pandas as pd
from duckdb import col
duckdb.__version__
# '2.0.0'
# In[2]:
# Table 1's id1 is a foreign key referenced by both table 2 and table 3
table_1_df = pd.DataFrame({
"id1": [1,2,3,4,5],
"data": [1,2,3,4,5],
})
# Table 2 and table 3 share a data column name, so table references and aliases are needed
table_2_df = pd.DataFrame({
"id2": list("abcde"),
"id1": [1,2,3,4,5],
"data": [1,2,3,4,5],
})
table_3_df = pd.DataFrame({
"id3": list("fghij"),
"id1": [1,2,3,4,5],
"data": [1,2,3,4,5],
})
con = duckdb.connect()
con.register("table_one", table_1_df)
table_1 = con.table("table_one")
con.register("table_two", table_2_df)
table_2 = con.table("table_two")
con.register("table_three", table_3_df)
table_3 = con.table("table_three")
# In[3]:
# When a join USING(id1) query is created, all is well
using_query = (table_1
.join(table_2, condition= 'id1')
.join(table_3, how="left", condition='id1')
)
using_query.select(
col("table_one", "id1"),
col("table_two", "data").alias("data2"),
col("table_three", "data").alias("data3"),
)
# id1
# BIGINT data2
# BIGINT data3
# BIGINT
# 1 1 1
# 2 2 2
# 3 3 3
# 4 4 4
# 5 5 5
# In[4]:
# When a join with an equality expression is used, it does not work
condition_query = (table_1
.join(table_2, condition= lambda left,right: left['id1'] == right['id1'])
.join(table_3, how="left", condition=lambda left,right: left['id1'] == right['id1'])
)
condition_query.select(
col("table_one", "id1"),
col("table_two", "data").alias("data2"),
col("table_three", "data").alias("data3"),
)
# ---------------------------------------------------------------------------
# BinderException Traceback (most recent call last)
# Cell In[4], line 7
# 3 .join(table_2, condition= lambda left,right: left['id1'] == right['id1'])
# 4 .join(table_3, how="left", condition=lambda left,right: left['id1'] == right['id1'])
# 5 )
# 6
# ----> 7 condition_query.select(
# 8 col("table_one", "id1"),
# 9 col("table_two", "data").alias("data2"),
# 10 col("table_three", "data").alias("data3"),
# File ~/develop/jds-sql/.venv/lib/python3.12/site-packages/duckdb/_relation.py:3017, in _closed_as_relation.<locals>.guarded(*args, **kwargs)
# 3015 raise _duckdb.ConnectionException(message) from None
# 3016 except _duckdb.Error as error:
# -> 3017 raise _trimmed(error) from error.__cause__
# BinderException: Binder Error: Referenced table "table_one" not found!
# Candidate tables: "table_three"
OS:
Ubuntu
DuckDB Package Version:
2.0.0
Python Version:
3.12.3
Full Name:
Janet Carson
Affiliation:
Echodyne
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 to reproduce the issue?
- Yes, I have
- Vorherrschende Sprache
- Python
- Sterne
- 203
- Forks
- 124
- Ø Merge
- 13 Std. 36 Min.
- Gemergte PRs (30 T.)
- 61
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus duckdb/duckdb-python
-
`read_json` accepts a list of paths at runtime but the type stub only allows a single path.Evtl. vergeben @aleks-drozy hat das vor 96 Tagen übernommen. Offenneeds triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
duckdb/duckdb-python#576 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Missing ROW_GROUPS_PER_FILE argument in write_parquet functionEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenneeds triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
duckdb/duckdb-python#386 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 66/100
duckdb/duckdb-python#737 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs triage
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
duckdb/duckdb-python#736 ·
Maintainer antworten meist innerhalb von 1 Tag
-
nanobind: leaked ... when a DuckDB type is referenced in overload signature and numpy is importedOffenneeds triage
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
duckdb/duckdb-python#732 · 5 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in duckdb/duckdb-python
Ähnliche Issues
-
[BUG]: Compliance rules never see Unity Catalog views as viewsEvtl. vergeben @wagnercsantos hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
databrickslabs/ontos#1348 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
`forum_pr_poster` action will always return `none` when checking for pre-existing feedback threads, even if a feedback thread already exists.Evtl. vergeben @pgmzeta hat das heute übernommen. OffenE-Verified P-Major
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
goonstation/goonstation#28259 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
woonstadrotterdam/monumenten#70 ·
Maintainer antworten meist innerhalb von 15 Tagen
-
binding:python bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
The Browser tab fails with a Wayland error when Open Terminal runs from a Wayland desktop sessionOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
open-webui/open-terminal#210 ·