Skip to content

Commit

Permalink
SNOW-1842455: fix pandas import in local testing (#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored Dec 3, 2024
1 parent 5d6b393 commit 769e7f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/mock/_nop_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Union,
)

import pandas
from snowflake.snowpark.mock._options import pandas

from snowflake.connector.cursor import ResultMetadata
from snowflake.snowpark._internal.analyzer.analyzer_utils import unquote_if_quoted
Expand Down
17 changes: 9 additions & 8 deletions src/snowflake/snowpark/mock/_snowflake_data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
#
from typing import Any, Dict, Iterable, NamedTuple, Optional, Union

from pandas.core.dtypes.common import (
is_bool_dtype,
is_float_dtype,
is_integer_dtype,
is_object_dtype,
is_string_dtype,
)

from snowflake.snowpark.mock._options import installed_pandas, pandas as pd
from snowflake.snowpark.mock._telemetry import LocalTestOOBTelemetryService
from snowflake.snowpark.mock.exceptions import SnowparkLocalTestingException
Expand Down Expand Up @@ -55,6 +47,13 @@

def infer_sp_type_from_python_type(p: Any) -> DataType:
"""helper function to map python types (using pandas) to Snowpark types."""
from pandas.core.dtypes.common import (
is_bool_dtype,
is_float_dtype,
is_integer_dtype,
is_object_dtype,
is_string_dtype,
)

# TODO SNOW-1826001: refactor this with Snowpark pandas to avoid redundancy.

Expand Down Expand Up @@ -535,6 +534,8 @@ def sf_type(self) -> ColumnType:
# due to ColumnEmulator inheriting from a pandas Series.
nullable = any([isna_helper(obj) for obj in self.values])

from pandas.core.dtypes.common import is_object_dtype

if is_object_dtype(self.dtype) and len(self) != 0:
# Infer from data when object type for the type to become more specific.
return ColumnType(
Expand Down

0 comments on commit 769e7f6

Please sign in to comment.