Skip to content

Commit

Permalink
fix(polars): columns are picked from the correct side in case of conf…
Browse files Browse the repository at this point in the history
…licting names (#8134)

Fixes #7345
  • Loading branch information
kszucs committed Feb 6, 2024
1 parent 12f7a56 commit 9703f6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions ibis/backends/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,7 @@ def test_memtable_column_naming_mismatch(backend, con, monkeypatch, df, columns)


@pytest.mark.notimpl(
["dask", "pandas", "polars"],
raises=NotImplementedError,
reason="not a SQL backend",
["dask", "pandas", "polars"], raises=NotImplementedError, reason="not a SQL backend"
)
@pytest.mark.notimpl(["flink"], reason="no sqlglot dialect", raises=ValueError)
def test_many_subqueries(con, snapshot):
Expand Down
20 changes: 20 additions & 0 deletions ibis/backends/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,23 @@ def test_complex_join_agg(snapshot):
expr = t1.left_join(t2, "key1").group_by(t1.key1).aggregate(avg_diff=avg_diff)

snapshot.assert_match(str(ibis.to_sql(expr, dialect="duckdb")), "out.sql")


def test_join_conflicting_columns(backend, con):
# GH #7345
t1 = ibis.memtable({"x": [1, 2, 3], "y": [4, 5, 6], "z": ["a", "b", "c"]})
t2 = ibis.memtable({"x": [3, 2, 1], "y": [7, 8, 9], "z": ["d", "e", "f"]})

expr = t1.join(t2, "x")
result = con.execute(expr).sort_values("x")

expected = pd.DataFrame(
{
"x": [1, 2, 3],
"y": [4, 5, 6],
"z": ["a", "b", "c"],
"y_right": [9, 8, 7],
"z_right": ["f", "e", "d"],
}
)
backend.assert_frame_equal(result, expected)

0 comments on commit 9703f6a

Please sign in to comment.