Skip to content

Commit

Permalink
chore: Check predicates in join_where (#18648)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Sep 10, 2024
1 parent 1ee6a82 commit 5658e65
Show file tree
Hide file tree
Showing 2 changed files with 7 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
6 changes: 6 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,9 @@ 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 5658e65

Please sign in to comment.