Skip to content

Commit d40820c

Browse files
SNOW-2467959: Add support for 9 date functions in faster pandas
1 parent a26070d commit d40820c

File tree

3 files changed

+347
-1
lines changed

3 files changed

+347
-1
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@
5757
- `str.lower`
5858
- `str.upper`
5959
- `str.title`
60-
60+
- `dt.tz_localize`
61+
- `dt.tz_convert`
62+
- `dt.ceil`
63+
- `dt.round`
64+
- `dt.floor`
65+
- `dt.normalize`
66+
- `dt.month_name`
67+
- `dt.day_name`
68+
- `dt.strftime`
6169
- Make faster pandas disabled by default (opt-in instead of opt-out).
6270

6371
## 1.41.0 (2025-10-23)

src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20987,6 +20987,34 @@ def dt_tz_localize(
2098720987
ambiguous: str = "raise",
2098820988
nonexistent: str = "raise",
2098920989
include_index: bool = False,
20990+
) -> "SnowflakeQueryCompiler":
20991+
"""
20992+
Wrapper around _dt_tz_localize_internal to be supported in faster pandas.
20993+
"""
20994+
relaxed_query_compiler = None
20995+
if self._relaxed_query_compiler is not None:
20996+
relaxed_query_compiler = (
20997+
self._relaxed_query_compiler._dt_tz_localize_internal(
20998+
tz=tz,
20999+
ambiguous=ambiguous,
21000+
nonexistent=nonexistent,
21001+
include_index=include_index,
21002+
)
21003+
)
21004+
qc = self._dt_tz_localize_internal(
21005+
tz=tz,
21006+
ambiguous=ambiguous,
21007+
nonexistent=nonexistent,
21008+
include_index=include_index,
21009+
)
21010+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21011+
21012+
def _dt_tz_localize_internal(
21013+
self,
21014+
tz: Union[str, tzinfo],
21015+
ambiguous: str = "raise",
21016+
nonexistent: str = "raise",
21017+
include_index: bool = False,
2099021018
) -> "SnowflakeQueryCompiler":
2099121019
"""
2099221020
Localize tz-naive to tz-aware.
@@ -21027,6 +21055,28 @@ def dt_tz_convert(
2102721055
self,
2102821056
tz: Union[str, tzinfo],
2102921057
include_index: bool = False,
21058+
) -> "SnowflakeQueryCompiler":
21059+
"""
21060+
Wrapper around _dt_tz_convert_internal to be supported in faster pandas.
21061+
"""
21062+
relaxed_query_compiler = None
21063+
if self._relaxed_query_compiler is not None:
21064+
relaxed_query_compiler = (
21065+
self._relaxed_query_compiler._dt_tz_convert_internal(
21066+
tz=tz,
21067+
include_index=include_index,
21068+
)
21069+
)
21070+
qc = self._dt_tz_convert_internal(
21071+
tz=tz,
21072+
include_index=include_index,
21073+
)
21074+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21075+
21076+
def _dt_tz_convert_internal(
21077+
self,
21078+
tz: Union[str, tzinfo],
21079+
include_index: bool = False,
2103021080
) -> "SnowflakeQueryCompiler":
2103121081
"""
2103221082
Convert time-series data to the specified time zone.
@@ -21060,6 +21110,32 @@ def dt_ceil(
2106021110
ambiguous: str = "raise",
2106121111
nonexistent: str = "raise",
2106221112
include_index: bool = False,
21113+
) -> "SnowflakeQueryCompiler":
21114+
"""
21115+
Wrapper around _dt_ceil_internal to be supported in faster pandas.
21116+
"""
21117+
relaxed_query_compiler = None
21118+
if self._relaxed_query_compiler is not None:
21119+
relaxed_query_compiler = self._relaxed_query_compiler._dt_ceil_internal(
21120+
freq=freq,
21121+
ambiguous=ambiguous,
21122+
nonexistent=nonexistent,
21123+
include_index=include_index,
21124+
)
21125+
qc = self._dt_ceil_internal(
21126+
freq=freq,
21127+
ambiguous=ambiguous,
21128+
nonexistent=nonexistent,
21129+
include_index=include_index,
21130+
)
21131+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21132+
21133+
def _dt_ceil_internal(
21134+
self,
21135+
freq: Frequency,
21136+
ambiguous: str = "raise",
21137+
nonexistent: str = "raise",
21138+
include_index: bool = False,
2106321139
) -> "SnowflakeQueryCompiler":
2106421140
"""
2106521141
Args:
@@ -21143,6 +21219,32 @@ def dt_round(
2114321219
ambiguous: str = "raise",
2114421220
nonexistent: str = "raise",
2114521221
include_index: bool = False,
21222+
) -> "SnowflakeQueryCompiler":
21223+
"""
21224+
Wrapper around _dt_round_internal to be supported in faster pandas.
21225+
"""
21226+
relaxed_query_compiler = None
21227+
if self._relaxed_query_compiler is not None:
21228+
relaxed_query_compiler = self._relaxed_query_compiler._dt_round_internal(
21229+
freq=freq,
21230+
ambiguous=ambiguous,
21231+
nonexistent=nonexistent,
21232+
include_index=include_index,
21233+
)
21234+
qc = self._dt_round_internal(
21235+
freq=freq,
21236+
ambiguous=ambiguous,
21237+
nonexistent=nonexistent,
21238+
include_index=include_index,
21239+
)
21240+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21241+
21242+
def _dt_round_internal(
21243+
self,
21244+
freq: Frequency,
21245+
ambiguous: str = "raise",
21246+
nonexistent: str = "raise",
21247+
include_index: bool = False,
2114621248
) -> "SnowflakeQueryCompiler":
2114721249
"""
2114821250
Args:
@@ -21304,6 +21406,32 @@ def dt_floor(
2130421406
ambiguous: str = "raise",
2130521407
nonexistent: str = "raise",
2130621408
include_index: bool = False,
21409+
) -> "SnowflakeQueryCompiler":
21410+
"""
21411+
Wrapper around _dt_floor_internal to be supported in faster pandas.
21412+
"""
21413+
relaxed_query_compiler = None
21414+
if self._relaxed_query_compiler is not None:
21415+
relaxed_query_compiler = self._relaxed_query_compiler._dt_floor_internal(
21416+
freq=freq,
21417+
ambiguous=ambiguous,
21418+
nonexistent=nonexistent,
21419+
include_index=include_index,
21420+
)
21421+
qc = self._dt_floor_internal(
21422+
freq=freq,
21423+
ambiguous=ambiguous,
21424+
nonexistent=nonexistent,
21425+
include_index=include_index,
21426+
)
21427+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21428+
21429+
def _dt_floor_internal(
21430+
self,
21431+
freq: Frequency,
21432+
ambiguous: str = "raise",
21433+
nonexistent: str = "raise",
21434+
include_index: bool = False,
2130721435
) -> "SnowflakeQueryCompiler":
2130821436
"""
2130921437
Args:
@@ -21374,6 +21502,22 @@ def floor_func(column: SnowparkColumn) -> SnowparkColumn:
2137421502
)
2137521503

2137621504
def dt_normalize(self, include_index: bool = False) -> "SnowflakeQueryCompiler":
21505+
"""
21506+
Wrapper around _dt_normalize_internal to be supported in faster pandas.
21507+
"""
21508+
relaxed_query_compiler = None
21509+
if self._relaxed_query_compiler is not None:
21510+
relaxed_query_compiler = (
21511+
self._relaxed_query_compiler._dt_normalize_internal(
21512+
include_index=include_index
21513+
)
21514+
)
21515+
qc = self._dt_normalize_internal(include_index=include_index)
21516+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21517+
21518+
def _dt_normalize_internal(
21519+
self, include_index: bool = False
21520+
) -> "SnowflakeQueryCompiler":
2137721521
"""
2137821522
Set the time component of each date-time value to midnight.
2137921523

@@ -21398,6 +21542,26 @@ def normalize_column(column: SnowparkColumn) -> SnowparkColumn:
2139821542

2139921543
def dt_month_name(
2140021544
self, locale: Optional[str] = None, include_index: bool = False
21545+
) -> "SnowflakeQueryCompiler":
21546+
"""
21547+
Wrapper around _dt_month_name_internal to be supported in faster pandas.
21548+
"""
21549+
relaxed_query_compiler = None
21550+
if self._relaxed_query_compiler is not None:
21551+
relaxed_query_compiler = (
21552+
self._relaxed_query_compiler._dt_month_name_internal(
21553+
locale=locale,
21554+
include_index=include_index,
21555+
)
21556+
)
21557+
qc = self._dt_month_name_internal(
21558+
locale=locale,
21559+
include_index=include_index,
21560+
)
21561+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21562+
21563+
def _dt_month_name_internal(
21564+
self, locale: Optional[str] = None, include_index: bool = False
2140121565
) -> "SnowflakeQueryCompiler":
2140221566
"""
2140321567
Args:
@@ -21432,6 +21596,24 @@ def month_name_func(column: SnowparkColumn) -> SnowparkColumn:
2143221596

2143321597
def dt_day_name(
2143421598
self, locale: Optional[str] = None, include_index: bool = False
21599+
) -> "SnowflakeQueryCompiler":
21600+
"""
21601+
Wrapper around _dt_day_name_internal to be supported in faster pandas.
21602+
"""
21603+
relaxed_query_compiler = None
21604+
if self._relaxed_query_compiler is not None:
21605+
relaxed_query_compiler = self._relaxed_query_compiler._dt_day_name_internal(
21606+
locale=locale,
21607+
include_index=include_index,
21608+
)
21609+
qc = self._dt_day_name_internal(
21610+
locale=locale,
21611+
include_index=include_index,
21612+
)
21613+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21614+
21615+
def _dt_day_name_internal(
21616+
self, locale: Optional[str] = None, include_index: bool = False
2143521617
) -> "SnowflakeQueryCompiler":
2143621618
"""
2143721619
Args:
@@ -21487,6 +21669,18 @@ def dt_total_seconds(self, include_index: bool = False) -> "SnowflakeQueryCompil
2148721669
)
2148821670

2148921671
def dt_strftime(self, date_format: str) -> "SnowflakeQueryCompiler":
21672+
"""
21673+
Wrapper around _dt_strftime_internal to be supported in faster pandas.
21674+
"""
21675+
relaxed_query_compiler = None
21676+
if self._relaxed_query_compiler is not None:
21677+
relaxed_query_compiler = self._relaxed_query_compiler._dt_strftime_internal(
21678+
date_format=date_format
21679+
)
21680+
qc = self._dt_strftime_internal(date_format=date_format)
21681+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21682+
21683+
def _dt_strftime_internal(self, date_format: str) -> "SnowflakeQueryCompiler":
2149021684
"""
2149121685
Format underlying date-time data using specified format.
2149221686

0 commit comments

Comments
 (0)