From 095e763fadf349eace8961bc7aaca21bf1bd199e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Sz=C5=B1cs?= Date: Tue, 27 Feb 2024 13:08:23 +0100 Subject: [PATCH] test(ir): cover join predicate dereferencing using tuple syntax --- ibis/expr/tests/test_newrels.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/ibis/expr/tests/test_newrels.py b/ibis/expr/tests/test_newrels.py index c444d9fff8f1..030a146a4e3c 100644 --- a/ibis/expr/tests/test_newrels.py +++ b/ibis/expr/tests/test_newrels.py @@ -769,6 +769,46 @@ def test_join_predicate_dereferencing(): ) +def test_join_predicate_dereferencing_using_tuple_syntax(): + # GH #8292 + + t = ibis.table(name="t", schema={"x": "int64", "y": "string"}) + t2 = t.mutate(x=_.x + 1) + t3 = t.mutate(x=_.x + 1) + t4 = t.mutate(x=_.x + 2) + + j1 = ibis.join(t2, t3, [(t2.x, t3.x)]) + j2 = ibis.join(t2, t4, [(t2.x, t4.x)]) + + with join_tables(t2, t3) as (r1, r2): + expected = ops.JoinChain( + first=r1, + rest=[ + ops.JoinLink("inner", r2, [r1.x == r2.x]), + ], + values={ + "x": r1.x, + "y": r1.y, + "y_right": r2.y, + }, + ) + assert j1.op() == expected + + with join_tables(t2, t4) as (r1, r2): + expected = ops.JoinChain( + first=r1, + rest=[ + ops.JoinLink("inner", r2, [r1.x == r2.x]), + ], + values={ + "x": r1.x, + "y": r1.y, + "y_right": r2.y, + }, + ) + assert j2.op() == expected + + def test_aggregate(): agg = t.aggregate(by=[t.bool_col], metrics=[t.int_col.sum()]) expected = Aggregate(