Skip to content

Commit

Permalink
chore: Check predicates in join_where
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 10, 2024
1 parent 1ee6a82 commit 072177d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/polars-plan/src/plans/conversion/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn resolve_join(
if matches!(options.args.how, JoinType::Cross) {
polars_ensure!(left_on.len() + right_on.len() == 0, InvalidOperation: "a 'cross' join doesn't expect any join keys");
} else {
polars_ensure!(left_on.len() + right_on.len() > 0, InvalidOperation: "expected join keys/predicates");
check_join_keys(&left_on)?;
check_join_keys(&right_on)?;

Expand Down
8 changes: 8 additions & 0 deletions py-polars/tests/unit/operations/test_inequality_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,11 @@ def test_raise_on_multiple_binary_comparisons() -> None:
df.join_where(
df, (pl.col("id") < pl.col("id")) & (pl.col("id") >= pl.col("id"))
)


def test_raise_invalid_input_join_where() -> None:
df = pl.DataFrame({"id": [1, 2]})
with pytest.raises(pl.exceptions.InvalidOperationError):
df.join_where(
df
)

0 comments on commit 072177d

Please sign in to comment.