Skip to content
Merged
4 changes: 2 additions & 2 deletions src/snowflake/snowpark/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ def _pandas_importer(): # noqa: E302
pandas = importlib.import_module("pandas")
# since we enable relative imports without dots this import gives us an issues when ran from test directory
from pandas import DataFrame # NOQA
except ImportError as e:
_logger.error(f"pandas is not installed {e}")
except ImportError:
pass
return pandas


Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#

import pytest
from snowflake.connector.options import MissingPandas

from snowflake.snowpark._internal import utils
from snowflake.snowpark._internal.utils import _pandas_importer


@pytest.mark.parametrize(
Expand Down Expand Up @@ -65,3 +67,12 @@ def test_split_path(path: str, expected_dir: str, expected_file: str) -> None:
def test_normalize_path(path: str, is_local: bool, expected: str) -> None:
actual = utils.normalize_path(path, is_local)
assert expected == actual


def test__pandas_importer():
imported_pandas = _pandas_importer()
try:
import pandas
assert imported_pandas == pandas
except ImportError:
assert imported_pandas == MissingPandas
Loading