Skip to content

Commit

Permalink
fix(joins): allow chaining positional and cross joins (#10122)
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth authored Sep 14, 2024
1 parent 0558319 commit e969eda
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions ibis/expr/tests/test_newrels.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,29 @@ def test_chained_join_referencing_intermediate_table():
assert isinstance(abc, ir.JoinExpr)


@pytest.mark.parametrize("how", ["positional", "cross"])
def test_chained_join_positional_cross(how):
a = ibis.table(name="a", schema={"a": "int64", "b": "string"})
b = ibis.table(name="b", schema={"c": "int64", "d": "string"})
c = ibis.table(name="c", schema={"e": "int64", "f": "string"})
joined = a.join(b, how=how).join(c, how=how)
result = joined._finish()

with join_tables(joined) as (r1, r2, r3):
assert result.op() == JoinChain(
first=r1,
rest=[JoinLink(how, r2, ()), JoinLink(how, r3, ())],
values={
"a": r1.a,
"b": r1.b,
"c": r2.c,
"d": r2.d,
"e": r3.e,
"f": r3.f,
},
)


def test_join_predicate_dereferencing():
# See #790, predicate pushdown in joins not supported

Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/types/joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _finish(self) -> Table:
def join(
self,
right,
predicates: Any,
predicates: Any = (),
how: JoinKind = "inner",
*,
lname: str = "",
Expand Down

0 comments on commit e969eda

Please sign in to comment.