Skip to content

Commit

Permalink
fix(exprs): ensure that left_semi and semi are equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 20, 2023
1 parent 87b8b63 commit bbc1eb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions ibis/backends/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,20 @@ def test_mutate_then_join_no_column_overlap(batting, awards_players):

@pytest.mark.notimpl(["datafusion", "bigquery", "druid"])
@pytest.mark.notyet(["dask"], reason="dask doesn't support descending order by")
def test_semi_join_topk(batting, awards_players):
@pytest.mark.parametrize(
"func",
[
param(lambda left, right: left.semi_join(right, "year"), id="method"),
param(
lambda left, right: left.join(right, "year", how="left_semi"),
id="how_left_semi",
),
param(lambda left, right: left.join(right, "year", how="semi"), id="how_semi"),
],
)
def test_semi_join_topk(batting, awards_players, func):
batting = batting.mutate(year=batting.yearID)
left = batting.semi_join(batting.year.topk(5), "year").select("year", "RBI")
left = func(batting, batting.year.topk(5)).select("year", "RBI")
expr = left.join(awards_players, left.year == awards_players.yearID)
assert not expr.limit(5).execute().empty

Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/types/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ def join(

# semi/anti join only give access to the left table's fields, so
# there's never overlap
if how in ("semi", "anti"):
if how in ("left_semi", "semi", "anti"):
return expr

return ops.relations._dedup_join_columns(expr, lname=lname, rname=rname)
Expand Down

0 comments on commit bbc1eb7

Please sign in to comment.