Skip to content

Commit

Permalink
fix import in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
EdAbati committed Jan 15, 2025
1 parent 482cd16 commit 12e9b39
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions narwhals/_spark_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
from typing import TYPE_CHECKING
from typing import Any

from pyspark.sql import types as pyspark_types

from narwhals.exceptions import InvalidIntoExprError
from narwhals.utils import import_dtypes_module
from narwhals.utils import isinstance_or_issubclass

if TYPE_CHECKING:
from pyspark.sql import Column
from pyspark.sql import types as pyspark_types

from narwhals._spark_like.dataframe import SparkLikeLazyFrame
from narwhals._spark_like.typing import IntoSparkLikeExpr
Expand All @@ -24,9 +23,10 @@ def native_to_narwhals_dtype(
dtype: pyspark_types.DataType,
version: Version,
) -> DType: # pragma: no cover
dtypes = import_dtypes_module(version=version)
from pyspark.sql import types as pyspark_types

dtypes = import_dtypes_module(version=version)

if isinstance(dtype, pyspark_types.DoubleType):
return dtypes.Float64()
if isinstance(dtype, pyspark_types.FloatType):
Expand Down Expand Up @@ -65,7 +65,10 @@ def native_to_narwhals_dtype(
def narwhals_to_native_dtype(
dtype: DType | type[DType], version: Version
) -> pyspark_types.DataType:
from pyspark.sql import types as pyspark_types

dtypes = import_dtypes_module(version)

if isinstance_or_issubclass(dtype, dtypes.Float64):
return pyspark_types.DoubleType()
if isinstance_or_issubclass(dtype, dtypes.Float32):
Expand Down

0 comments on commit 12e9b39

Please sign in to comment.