Skip to content

Commit

Permalink
fix(snowflake): initialize _from_snowpark variable in constructor t…
Browse files Browse the repository at this point in the history
…o ensure it is defined (#8970)

Fixes an issue with the `_from_snowpark` instance variable being used before it is defined.
  • Loading branch information
cpcloud authored Apr 15, 2024
1 parent e31eded commit 5722a10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Backend(SQLBackend, CanCreateCatalog, CanCreateDatabase, CanCreateSchema):
_latest_udf_python_version = (3, 10)
_top_level_methods = ("from_snowpark",)

def __init__(self, _from_snowpark: bool = False) -> None:
self._from_snowpark = _from_snowpark

def _convert_kwargs(self, kwargs):
with contextlib.suppress(KeyError):
kwargs["account"] = kwargs.pop("host")
Expand Down Expand Up @@ -217,7 +220,6 @@ def do_connect(self, create_object_udfs: bool = True, **kwargs: Any):
session_parameters=session_parameters,
create_object_udfs=create_object_udfs,
)
self._from_snowpark = False

def _setup_session(self, *, con, session_parameters, create_object_udfs: bool):
self.con = con
Expand Down Expand Up @@ -315,13 +317,12 @@ def from_snowpark(cls, session, *, create_object_udfs: bool = True) -> Backend:
│ ansonca01 │ 16 │
└───────────┴───────┘
"""
backend = cls()
backend = cls(_from_snowpark=True)
backend._setup_session(
con=session._conn._conn,
session_parameters={},
create_object_udfs=create_object_udfs,
)
backend._from_snowpark = True
return backend

def reconnect(self) -> None:
Expand Down

0 comments on commit 5722a10

Please sign in to comment.