Skip to content

Commit

Permalink
feat(snowflake): implement support for asof_join API (ibis-project#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored May 13, 2024
1 parent bee1da5 commit 49c6ce3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 15 additions & 0 deletions ibis/backends/snowflake/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions ibis/backends/tests/test_asof_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def time_keyed_right(time_keyed_df2):
@pytest.mark.notyet(
[
"datafusion",
"snowflake",
"trino",
"postgres",
"mysql",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 49c6ce3

Please sign in to comment.