Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Raise on suffixed predicate in join_where #18607

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/polars-plan/src/plans/conversion/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ fn resolve_join_where(
let original_right = right;

for name in aexpr_to_leaf_names(right, ctxt.expr_arena) {
polars_ensure!(schema_right.contains(name.as_str()), ColumnNotFound: "could not find column {name} in the right table during join operation");
if schema_left.contains(name.as_str()) {
let new_name = _join_suffix_name(name.as_str(), suffix.as_str());
polars_ensure!(schema_right.contains(name.as_str()), ColumnNotFound: "could not find column {name} in the right table during join operation");

right = rename_matching_aexpr_leaf_names(
right,
Expand Down
9 changes: 7 additions & 2 deletions py-polars/tests/unit/operations/test_inequality_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import hypothesis.strategies as st
import numpy as np
import pytest
from hypothesis import given

import polars as pl
Expand Down Expand Up @@ -436,9 +437,13 @@ def test_ie_join_with_floats(
expr0 = _inequality_expression("dur", op1, "time")
expr1 = _inequality_expression("rev", op2, "cost")

print(east, west)
actual = east.join_where(west, expr0, expr1)
print(actual)

expected = east.join(west, how="cross").filter(expr0 & expr1)
assert_frame_equal(actual, expected, check_row_order=False, check_exact=True)


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