diff --git a/ibis/backends/flink/tests/snapshots/test_join/test_join_then_filter_no_column_overlap/out.sql b/ibis/backends/flink/tests/snapshots/test_join/test_join_then_filter_no_column_overlap/out.sql new file mode 100644 index 000000000000..b4da52906175 --- /dev/null +++ b/ibis/backends/flink/tests/snapshots/test_join/test_join_then_filter_no_column_overlap/out.sql @@ -0,0 +1,19 @@ +WITH t0 AS ( + SELECT t3.* + FROM batting t3 + WHERE t3.`yearID` = 2015 +), +t1 AS ( + SELECT t3.* + FROM awards_players t3 + WHERE t3.`lgID` = 'NL' +), +t2 AS ( + SELECT t0.`yearID` AS `year`, t0.`RBI` + FROM t0 +) +SELECT * +FROM t2 + INNER JOIN t1 + ON t2.`year` = t1.`yearID` +WHERE `RBI` = 9 \ No newline at end of file diff --git a/ibis/backends/flink/tests/snapshots/test_join/test_mutate_then_join_no_column_overlap/out.sql b/ibis/backends/flink/tests/snapshots/test_join/test_mutate_then_join_no_column_overlap/out.sql new file mode 100644 index 000000000000..544d07b36672 --- /dev/null +++ b/ibis/backends/flink/tests/snapshots/test_join/test_mutate_then_join_no_column_overlap/out.sql @@ -0,0 +1,18 @@ +WITH t0 AS ( + SELECT t4.*, t4.`yearID` AS `year` + FROM batting t4 +), +t1 AS ( + SELECT t0.* + FROM t0 + WHERE t0.`year` = 2015 +), +t2 AS ( + SELECT t1.`year`, t1.`RBI` + FROM t1 +) +SELECT * +FROM t2 + INNER JOIN awards_players t3 + ON t2.`year` = t3.`yearID` +LIMIT 5 \ No newline at end of file diff --git a/ibis/backends/flink/tests/test_join.py b/ibis/backends/flink/tests/test_join.py index f1a3b2090bdc..f31f07afc9ac 100644 --- a/ibis/backends/flink/tests/test_join.py +++ b/ibis/backends/flink/tests/test_join.py @@ -13,3 +13,25 @@ def test_mutating_join(batting, awards_players, how, snapshot): expr = left.join(right, predicate, how=how) result = translate(expr.as_table().op()) snapshot.assert_match(str(result), "out.sql") + + +def test_join_then_filter_no_column_overlap(awards_players, batting, snapshot): + left = batting[batting.yearID == 2015] + year = left.yearID.name("year") + left = left[year, "RBI"] + right = awards_players[awards_players.lgID == 'NL'] + + expr = left.join(right, left.year == right.yearID) + filters = [expr.RBI == 9] + q = expr.filter(filters) + result = translate(q.as_table().op()) + snapshot.assert_match(str(result), "out.sql") + + +def test_mutate_then_join_no_column_overlap(batting, awards_players, snapshot): + left = batting.mutate(year=batting.yearID).filter(lambda t: t.year == 2015) + left = left["year", "RBI"] + right = awards_players + expr = left.join(right, left.year == right.yearID) + result = translate(expr.limit(5).as_table().op()) + snapshot.assert_match(str(result), "out.sql")