From 49c6ce3cc95aa72953bb5d53c7230cdb980a2680 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 13 May 2024 10:59:33 -0400 Subject: [PATCH] feat(snowflake): implement support for `asof_join` API (#9180) --- ibis/backends/snowflake/compiler.py | 15 +++++++++++++++ ibis/backends/tests/test_asof_join.py | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ibis/backends/snowflake/compiler.py b/ibis/backends/snowflake/compiler.py index 932a322542d2..c854ad25887c 100644 --- a/ibis/backends/snowflake/compiler.py +++ b/ibis/backends/snowflake/compiler.py @@ -651,3 +651,18 @@ def visit_ArrayFilter(self, op, *, arg, param, body): expressions=[param], ), ) + + def visit_JoinLink(self, op, *, how, table, predicates): + assert ( + predicates or how == "cross" + ), "expected non-empty predicates when not a cross join" + + if how == "asof": + # the asof join match condition is always the first predicate by + # construction + match_condition, *predicates = predicates + on = sg.and_(*predicates) if predicates else None + return sge.Join( + this=table, kind=how, on=on, match_condition=match_condition + ) + return super().visit_JoinLink(op, how=how, table=table, predicates=predicates) diff --git a/ibis/backends/tests/test_asof_join.py b/ibis/backends/tests/test_asof_join.py index 468ba85772e6..bcf253c709d5 100644 --- a/ibis/backends/tests/test_asof_join.py +++ b/ibis/backends/tests/test_asof_join.py @@ -84,7 +84,6 @@ def time_keyed_right(time_keyed_df2): @pytest.mark.notyet( [ "datafusion", - "snowflake", "trino", "postgres", "mysql", @@ -126,7 +125,6 @@ def test_asof_join(con, time_left, time_right, time_df1, time_df2, direction, op @pytest.mark.notyet( [ "datafusion", - "snowflake", "trino", "postgres", "mysql",