Skip to content

Commit

Permalink
[sql 169/208] test(joins): add test for ibis-project#7288.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 21, 2023
1 parent d08393c commit daea5de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SELECT
t3.key1 AS key1,
AVG(t3.value1 - t3.value2) AS avg_diff
FROM (
SELECT
t0.value1 AS value1,
t0.key1 AS key1,
t0.key2 AS key2,
t1.value2 AS value2,
t1.key1 AS key1_right,
t1.key4 AS key4
FROM table1 AS t0
LEFT OUTER JOIN table2 AS t1
ON t0.key1 = t1.key1
) AS t3
GROUP BY
1
10 changes: 10 additions & 0 deletions ibis/backends/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,13 @@ def test_outer_join_nullability(backend, how, nrows, gen_right, keys):

result = expr.to_pyarrow()
assert len(result) == nrows


def test_complex_join_agg(snapshot):
t1 = ibis.table(dict(value1="float", key1="string", key2="string"), name="table1")
t2 = ibis.table(dict(value2="float", key1="string", key4="string"), name="table2")

avg_diff = (t1.value1 - t2.value2).mean()
expr = t1.left_join(t2, "key1").group_by(t1.key1).aggregate(avg_diff=avg_diff)

snapshot.assert_match(str(ibis.to_sql(expr, dialect="duckdb")), "out.sql")

0 comments on commit daea5de

Please sign in to comment.