Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update import logic to remove pyspark dependency from Snowflake Offline Store #3397

Merged
merged 4 commits into from
Dec 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sdk/python/feast/infra/offline_stores/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import reduce
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Callable,
ContextManager,
Expand Down Expand Up @@ -63,12 +64,8 @@

raise FeastExtrasDependencyImportError("snowflake", str(e))

try:
if TYPE_CHECKING:
from pyspark.sql import DataFrame, SparkSession
except ImportError as e:
from feast.errors import FeastExtrasDependencyImportError

raise FeastExtrasDependencyImportError("spark", str(e))

warnings.filterwarnings("ignore", category=DeprecationWarning)

Expand Down Expand Up @@ -462,7 +459,7 @@ def to_sql(self) -> str:
with self._query_generator() as query:
return query

def to_spark_df(self, spark_session: SparkSession) -> DataFrame:
def to_spark_df(self, spark_session: "SparkSession") -> "DataFrame":
"""
Method to convert snowflake query results to pyspark data frame.

Expand All @@ -473,6 +470,13 @@ def to_spark_df(self, spark_session: SparkSession) -> DataFrame:
spark_df: A pyspark dataframe.
"""

try:
from pyspark.sql import DataFrame, SparkSession
except ImportError as e:
from feast.errors import FeastExtrasDependencyImportError

raise FeastExtrasDependencyImportError("spark", str(e))

if isinstance(spark_session, SparkSession):
with self._query_generator() as query:

Expand Down