Skip to content

Commit

Permalink
fix(duckdb-sql): ignore importlib package errors when importing ibis.…
Browse files Browse the repository at this point in the history
…snowflake for transpilation (#8389)

Fixes an issue where we try to pluck package metadata for a non-existent
package (`snowflake-connector-python`) when transpiling from one dialect
to another; in this case duckdb sql to snowflake sql.
  • Loading branch information
cpcloud authored Feb 18, 2024
1 parent c4ef23f commit b968301
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 0 additions & 2 deletions ibis/backends/duckdb/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ def test_insert(con):


def test_to_other_sql(con, snapshot):
pytest.importorskip("snowflake.connector")

t = con.table("functional_alltypes")

sql = ibis.to_sql(t, dialect="snowflake")
Expand Down
22 changes: 11 additions & 11 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@
from ibis.backends.snowflake.compiler import SnowflakeCompiler
from ibis.backends.snowflake.converter import SnowflakePandasData

with warnings.catch_warnings():
if vparse(importlib.metadata.version("snowflake-connector-python")) >= vparse(
"3.3.0"
):
warnings.filterwarnings(
"ignore",
message="You have an incompatible version of 'pyarrow' installed",
category=UserWarning,
)
import snowflake.connector as sc

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator, Mapping

Expand Down Expand Up @@ -222,6 +211,17 @@ def do_connect(self, create_object_udfs: bool = True, **kwargs: Any):
Additional arguments passed to the URL constructor.
"""
with warnings.catch_warnings():
if vparse(
importlib.metadata.version("snowflake-connector-python")
) >= vparse("3.3.0"):
warnings.filterwarnings(
"ignore",
message="You have an incompatible version of 'pyarrow' installed",
category=UserWarning,
)
import snowflake.connector as sc

connect_args = kwargs.copy()
session_parameters = connect_args.pop("session_parameters", {})

Expand Down

0 comments on commit b968301

Please sign in to comment.