Skip to content

Commit

Permalink
tests: check semi_join raises when can't infer on arg
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Jan 19, 2022
1 parent 6e28c4d commit 6af4e28
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion siuba/dply/verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ def semi_join(left, right = None, on = None):

on_cols = list(set(left.columns).intersection(set(right.columns)))
if not len(on_cols):
raise Exception("No joining column specified, and no shared column names")
raise Exception("No join column specified, and no shared column names")

warnings.warn("Detected shared columns: %s" % on_cols)
elif isinstance(on, str):
Expand Down
2 changes: 1 addition & 1 deletion siuba/sql/verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ def _validate_join_arg_on(on, sql_on = None, lhs = None, rhs = None):

if not on_cols:
raise ValueError(
"No on columns specified, or shared column names in join."
"No join column specified, or shared column names in join."
)

# trivial dict mapping shared names to themselves
Expand Down
8 changes: 8 additions & 0 deletions siuba/tests/test_verb_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ def test_semi_join_no_on_arg(backend, df1):
assert "No on column passed to join." in record[0].message.args[0]
assert "['ii']" in record[1].message.args[0]

def test_semi_join_no_on_arg_fail(backend, df1):
df_ii = backend.load_df(data_frame(ZZ = [1,1]))

with pytest.raises(Exception) as excinfo:
collect(semi_join(df1, df_ii))

assert "No join column specified" in str(excinfo.value)


def test_basic_anti_join_on_map(backend, df1, df2):
assert_frame_sort_equal(
Expand Down

0 comments on commit 6af4e28

Please sign in to comment.