Skip to content

Commit

Permalink
fix(snowflake): fix broken unnest functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jul 18, 2023
1 parent b77a334 commit 207587c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import itertools
import os
import platform
import re
import shutil
import sys
import tempfile
Expand All @@ -17,6 +18,7 @@
import sqlalchemy.types as sat
from snowflake.connector.constants import FIELD_ID_TO_NAME
from snowflake.sqlalchemy import ARRAY, OBJECT, URL
from sqlalchemy.ext.compiler import compiles

import ibis
import ibis.expr.datatypes as dt
Expand Down Expand Up @@ -499,3 +501,14 @@ def _get_temp_view_definition(
self, name: str, definition: sa.sql.compiler.Compiled
) -> str:
yield f"CREATE OR REPLACE TEMPORARY VIEW {name} AS {definition}"


@compiles(sa.sql.Join, "snowflake")
def compile_join(element, compiler, **kw):
result = compiler.visit_join(element, **kw)

# snowflake doesn't support lateral joins with ON clauses as of
# https://docs.snowflake.com/en/release-notes/bcr-bundles/2023_04/bcr-1057
if element.right._is_lateral:
return re.sub(r"^(.+) ON true$", r"\1", result, flags=re.IGNORECASE)
return result

0 comments on commit 207587c

Please sign in to comment.