Skip to content

Commit 905bf84

Browse files
SNOW-2467959: Add support for 9 date functions in faster pandas (#3970)
1 parent d1ea92c commit 905bf84

File tree

3 files changed

+347
-0
lines changed

3 files changed

+347
-0
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@
7373
- `str.lstrip`
7474
- `str.rstrip`
7575
- `str.translate`
76+
- `dt.tz_localize`
77+
- `dt.tz_convert`
78+
- `dt.ceil`
79+
- `dt.round`
80+
- `dt.floor`
81+
- `dt.normalize`
82+
- `dt.month_name`
83+
- `dt.day_name`
84+
- `dt.strftime`
7685
- Make faster pandas disabled by default (opt-in instead of opt-out).
7786

7887
## 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
@@ -21255,6 +21255,34 @@ def dt_tz_localize(
2125521255
ambiguous: str = "raise",
2125621256
nonexistent: str = "raise",
2125721257
include_index: bool = False,
21258+
) -> "SnowflakeQueryCompiler":
21259+
"""
21260+
Wrapper around _dt_tz_localize_internal to be supported in faster pandas.
21261+
"""
21262+
relaxed_query_compiler = None
21263+
if self._relaxed_query_compiler is not None:
21264+
relaxed_query_compiler = (
21265+
self._relaxed_query_compiler._dt_tz_localize_internal(
21266+
tz=tz,
21267+
ambiguous=ambiguous,
21268+
nonexistent=nonexistent,
21269+
include_index=include_index,
21270+
)
21271+
)
21272+
qc = self._dt_tz_localize_internal(
21273+
tz=tz,
21274+
ambiguous=ambiguous,
21275+
nonexistent=nonexistent,
21276+
include_index=include_index,
21277+
)
21278+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21279+
21280+
def _dt_tz_localize_internal(
21281+
self,
21282+
tz: Union[str, tzinfo],
21283+
ambiguous: str = "raise",
21284+
nonexistent: str = "raise",
21285+
include_index: bool = False,
2125821286
) -> "SnowflakeQueryCompiler":
2125921287
"""
2126021288
Localize tz-naive to tz-aware.
@@ -21295,6 +21323,28 @@ def dt_tz_convert(
2129521323
self,
2129621324
tz: Union[str, tzinfo],
2129721325
include_index: bool = False,
21326+
) -> "SnowflakeQueryCompiler":
21327+
"""
21328+
Wrapper around _dt_tz_convert_internal to be supported in faster pandas.
21329+
"""
21330+
relaxed_query_compiler = None
21331+
if self._relaxed_query_compiler is not None:
21332+
relaxed_query_compiler = (
21333+
self._relaxed_query_compiler._dt_tz_convert_internal(
21334+
tz=tz,
21335+
include_index=include_index,
21336+
)
21337+
)
21338+
qc = self._dt_tz_convert_internal(
21339+
tz=tz,
21340+
include_index=include_index,
21341+
)
21342+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21343+
21344+
def _dt_tz_convert_internal(
21345+
self,
21346+
tz: Union[str, tzinfo],
21347+
include_index: bool = False,
2129821348
) -> "SnowflakeQueryCompiler":
2129921349
"""
2130021350
Convert time-series data to the specified time zone.
@@ -21328,6 +21378,32 @@ def dt_ceil(
2132821378
ambiguous: str = "raise",
2132921379
nonexistent: str = "raise",
2133021380
include_index: bool = False,
21381+
) -> "SnowflakeQueryCompiler":
21382+
"""
21383+
Wrapper around _dt_ceil_internal to be supported in faster pandas.
21384+
"""
21385+
relaxed_query_compiler = None
21386+
if self._relaxed_query_compiler is not None:
21387+
relaxed_query_compiler = self._relaxed_query_compiler._dt_ceil_internal(
21388+
freq=freq,
21389+
ambiguous=ambiguous,
21390+
nonexistent=nonexistent,
21391+
include_index=include_index,
21392+
)
21393+
qc = self._dt_ceil_internal(
21394+
freq=freq,
21395+
ambiguous=ambiguous,
21396+
nonexistent=nonexistent,
21397+
include_index=include_index,
21398+
)
21399+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21400+
21401+
def _dt_ceil_internal(
21402+
self,
21403+
freq: Frequency,
21404+
ambiguous: str = "raise",
21405+
nonexistent: str = "raise",
21406+
include_index: bool = False,
2133121407
) -> "SnowflakeQueryCompiler":
2133221408
"""
2133321409
Args:
@@ -21411,6 +21487,32 @@ def dt_round(
2141121487
ambiguous: str = "raise",
2141221488
nonexistent: str = "raise",
2141321489
include_index: bool = False,
21490+
) -> "SnowflakeQueryCompiler":
21491+
"""
21492+
Wrapper around _dt_round_internal to be supported in faster pandas.
21493+
"""
21494+
relaxed_query_compiler = None
21495+
if self._relaxed_query_compiler is not None:
21496+
relaxed_query_compiler = self._relaxed_query_compiler._dt_round_internal(
21497+
freq=freq,
21498+
ambiguous=ambiguous,
21499+
nonexistent=nonexistent,
21500+
include_index=include_index,
21501+
)
21502+
qc = self._dt_round_internal(
21503+
freq=freq,
21504+
ambiguous=ambiguous,
21505+
nonexistent=nonexistent,
21506+
include_index=include_index,
21507+
)
21508+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21509+
21510+
def _dt_round_internal(
21511+
self,
21512+
freq: Frequency,
21513+
ambiguous: str = "raise",
21514+
nonexistent: str = "raise",
21515+
include_index: bool = False,
2141421516
) -> "SnowflakeQueryCompiler":
2141521517
"""
2141621518
Args:
@@ -21572,6 +21674,32 @@ def dt_floor(
2157221674
ambiguous: str = "raise",
2157321675
nonexistent: str = "raise",
2157421676
include_index: bool = False,
21677+
) -> "SnowflakeQueryCompiler":
21678+
"""
21679+
Wrapper around _dt_floor_internal to be supported in faster pandas.
21680+
"""
21681+
relaxed_query_compiler = None
21682+
if self._relaxed_query_compiler is not None:
21683+
relaxed_query_compiler = self._relaxed_query_compiler._dt_floor_internal(
21684+
freq=freq,
21685+
ambiguous=ambiguous,
21686+
nonexistent=nonexistent,
21687+
include_index=include_index,
21688+
)
21689+
qc = self._dt_floor_internal(
21690+
freq=freq,
21691+
ambiguous=ambiguous,
21692+
nonexistent=nonexistent,
21693+
include_index=include_index,
21694+
)
21695+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21696+
21697+
def _dt_floor_internal(
21698+
self,
21699+
freq: Frequency,
21700+
ambiguous: str = "raise",
21701+
nonexistent: str = "raise",
21702+
include_index: bool = False,
2157521703
) -> "SnowflakeQueryCompiler":
2157621704
"""
2157721705
Args:
@@ -21642,6 +21770,22 @@ def floor_func(column: SnowparkColumn) -> SnowparkColumn:
2164221770
)
2164321771

2164421772
def dt_normalize(self, include_index: bool = False) -> "SnowflakeQueryCompiler":
21773+
"""
21774+
Wrapper around _dt_normalize_internal to be supported in faster pandas.
21775+
"""
21776+
relaxed_query_compiler = None
21777+
if self._relaxed_query_compiler is not None:
21778+
relaxed_query_compiler = (
21779+
self._relaxed_query_compiler._dt_normalize_internal(
21780+
include_index=include_index
21781+
)
21782+
)
21783+
qc = self._dt_normalize_internal(include_index=include_index)
21784+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21785+
21786+
def _dt_normalize_internal(
21787+
self, include_index: bool = False
21788+
) -> "SnowflakeQueryCompiler":
2164521789
"""
2164621790
Set the time component of each date-time value to midnight.
2164721791

@@ -21666,6 +21810,26 @@ def normalize_column(column: SnowparkColumn) -> SnowparkColumn:
2166621810

2166721811
def dt_month_name(
2166821812
self, locale: Optional[str] = None, include_index: bool = False
21813+
) -> "SnowflakeQueryCompiler":
21814+
"""
21815+
Wrapper around _dt_month_name_internal to be supported in faster pandas.
21816+
"""
21817+
relaxed_query_compiler = None
21818+
if self._relaxed_query_compiler is not None:
21819+
relaxed_query_compiler = (
21820+
self._relaxed_query_compiler._dt_month_name_internal(
21821+
locale=locale,
21822+
include_index=include_index,
21823+
)
21824+
)
21825+
qc = self._dt_month_name_internal(
21826+
locale=locale,
21827+
include_index=include_index,
21828+
)
21829+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21830+
21831+
def _dt_month_name_internal(
21832+
self, locale: Optional[str] = None, include_index: bool = False
2166921833
) -> "SnowflakeQueryCompiler":
2167021834
"""
2167121835
Args:
@@ -21700,6 +21864,24 @@ def month_name_func(column: SnowparkColumn) -> SnowparkColumn:
2170021864

2170121865
def dt_day_name(
2170221866
self, locale: Optional[str] = None, include_index: bool = False
21867+
) -> "SnowflakeQueryCompiler":
21868+
"""
21869+
Wrapper around _dt_day_name_internal to be supported in faster pandas.
21870+
"""
21871+
relaxed_query_compiler = None
21872+
if self._relaxed_query_compiler is not None:
21873+
relaxed_query_compiler = self._relaxed_query_compiler._dt_day_name_internal(
21874+
locale=locale,
21875+
include_index=include_index,
21876+
)
21877+
qc = self._dt_day_name_internal(
21878+
locale=locale,
21879+
include_index=include_index,
21880+
)
21881+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21882+
21883+
def _dt_day_name_internal(
21884+
self, locale: Optional[str] = None, include_index: bool = False
2170321885
) -> "SnowflakeQueryCompiler":
2170421886
"""
2170521887
Args:
@@ -21755,6 +21937,18 @@ def dt_total_seconds(self, include_index: bool = False) -> "SnowflakeQueryCompil
2175521937
)
2175621938

2175721939
def dt_strftime(self, date_format: str) -> "SnowflakeQueryCompiler":
21940+
"""
21941+
Wrapper around _dt_strftime_internal to be supported in faster pandas.
21942+
"""
21943+
relaxed_query_compiler = None
21944+
if self._relaxed_query_compiler is not None:
21945+
relaxed_query_compiler = self._relaxed_query_compiler._dt_strftime_internal(
21946+
date_format=date_format
21947+
)
21948+
qc = self._dt_strftime_internal(date_format=date_format)
21949+
return self._maybe_set_relaxed_qc(qc, relaxed_query_compiler)
21950+
21951+
def _dt_strftime_internal(self, date_format: str) -> "SnowflakeQueryCompiler":
2175821952
"""
2175921953
Format underlying date-time data using specified format.
2176021954

0 commit comments

Comments
 (0)