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

feat(api): support passing Deferreds as predicates to joins #10704

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions ibis/backends/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,20 @@ def test_positional_join(backend, con):
result = con.execute(j)
expected = pd.DataFrame({"x": [1, 2, 3], "x_right": [3, 2, 1]})
backend.assert_frame_equal(result, expected)


@pytest.mark.parametrize(
"preds",
[
pytest.param(ibis._.x.upper(), id="single"),
pytest.param([ibis._.x.upper()], id="single-list"),
pytest.param([ibis._.x.upper(), ibis._.x.lower()], id="multiple"),
],
)
def test_join_deferred(backend: BackendTest, con, preds):
t1 = ibis.memtable({"x": ["a", "b", "c"]})
t2 = ibis.memtable({"x": ["A", "B", "Z"]})
j = t1.inner_join(t2, predicates=preds)
result = con.execute(j)
expected = pd.DataFrame({"x": ["a", "b"], "x_right": ["A", "B"]})
backend.assert_frame_equal(result, expected)
3 changes: 1 addition & 2 deletions ibis/expr/types/joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import ibis.expr.operations as ops
from ibis import util
from ibis.common.deferred import Deferred
from ibis.common.egraph import DisjointSet
from ibis.common.exceptions import (
ExpressionError,
Expand Down Expand Up @@ -168,7 +167,7 @@ def prepare_predicates(

left, right = chain.to_expr(), right.to_expr()
for pred in util.promote_list(predicates):
if isinstance(pred, (Value, Deferred, bool)):
if isinstance(pred, (Value, bool)):
for bound in bind(left, pred):
yield deref_both.dereference(bound.op())
else:
Expand Down
Loading