22
33from typing import TYPE_CHECKING
44
5- from narwhals ._compliant import LazyExprNamespace
6- from narwhals ._compliant .any_namespace import DateTimeNamespace
75from narwhals ._constants import US_PER_SECOND
86from narwhals ._duration import Interval
97from narwhals ._spark_like .utils import (
108 UNITS_DICT ,
119 fetch_session_time_zone ,
1210 strptime_to_pyspark_format ,
1311)
12+ from narwhals ._sql .expr_dt import SQLExprDateTimeNamesSpace
1413from narwhals ._utils import not_implemented
1514
1615if TYPE_CHECKING :
2221 from narwhals ._spark_like .expr import SparkLikeExpr
2322
2423
25- class SparkLikeExprDateTimeNamespace (
26- LazyExprNamespace ["SparkLikeExpr" ], DateTimeNamespace ["SparkLikeExpr" ]
27- ):
24+ class SparkLikeExprDateTimeNamespace (SQLExprDateTimeNamesSpace ["SparkLikeExpr" ]):
2825 def _weekday (self , expr : Column ) -> Column :
2926 # PySpark's dayofweek returns 1-7 for Sunday-Saturday
3027 return (self .compliant ._F .dayofweek (expr ) + 6 ) % 7
@@ -63,27 +60,6 @@ def _to_string(expr: Column) -> Column:
6360
6461 return self .compliant ._with_elementwise (_to_string )
6562
66- def date (self ) -> SparkLikeExpr :
67- return self .compliant ._with_elementwise (self .compliant ._F .to_date )
68-
69- def year (self ) -> SparkLikeExpr :
70- return self .compliant ._with_elementwise (self .compliant ._F .year )
71-
72- def month (self ) -> SparkLikeExpr :
73- return self .compliant ._with_elementwise (self .compliant ._F .month )
74-
75- def day (self ) -> SparkLikeExpr :
76- return self .compliant ._with_elementwise (self .compliant ._F .day )
77-
78- def hour (self ) -> SparkLikeExpr :
79- return self .compliant ._with_elementwise (self .compliant ._F .hour )
80-
81- def minute (self ) -> SparkLikeExpr :
82- return self .compliant ._with_elementwise (self .compliant ._F .minute )
83-
84- def second (self ) -> SparkLikeExpr :
85- return self .compliant ._with_elementwise (self .compliant ._F .second )
86-
8763 def millisecond (self ) -> SparkLikeExpr :
8864 def _millisecond (expr : Column ) -> Column :
8965 return self .compliant ._F .floor (
@@ -104,9 +80,6 @@ def _nanosecond(expr: Column) -> Column:
10480
10581 return self .compliant ._with_elementwise (_nanosecond )
10682
107- def ordinal_day (self ) -> SparkLikeExpr :
108- return self .compliant ._with_elementwise (self .compliant ._F .dayofyear )
109-
11083 def weekday (self ) -> SparkLikeExpr :
11184 return self .compliant ._with_elementwise (self ._weekday )
11285
0 commit comments