Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/cudf_polars/cudf_polars/dsl/expressions/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def from_polars(cls, obj: polars._expr_nodes.TemporalFunction) -> Self:
# Divisor used to derive the century/millennium from the calendar year:
# ``(year - 1) // divisor + 1`` (floor division, matching polars).
_CENTURY_MILLENNIUM_DIVISOR: ClassVar[dict[Name, int]] = {
Name.Millennium: 1_000,
Name.Century: 100,
}
_valid_ops: ClassVar[set[Name]] = {
Expand All @@ -150,7 +151,7 @@ def from_polars(cls, obj: polars._expr_nodes.TemporalFunction) -> Self:
Name.TimeStamp,
Name.CastTimeUnit,
Name.Truncate,
Name.Century,
*_CENTURY_MILLENNIUM_DIVISOR.keys(),
*_TOTAL_COMPONENT_NANOSECONDS.keys(),
}

Expand Down Expand Up @@ -246,8 +247,6 @@ def do_evaluate(
stream=df.stream,
)
# polars computes ``(year - 1) // divisor + 1`` using floor division;
# evaluate the whole arithmetic as a single fused libcudf AST
# expression rather than three separate binaryop kernels.
one = plc.expressions.Literal(
plc.Scalar.from_py(1, int32, stream=df.stream)
)
Expand Down
4 changes: 2 additions & 2 deletions python/cudf_polars/tests/expressions/test_datetime_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_duration_total_component_extract(engine: pl.GPUEngine, field, dtype):
assert_gpu_result_equal(q, engine=engine)


@pytest.mark.parametrize("method", ["century"])
@pytest.mark.parametrize("method", ["century", "millennium"])
@pytest.mark.parametrize(
"dtype", [pl.Date(), pl.Datetime("ms"), pl.Datetime("us"), pl.Datetime("ns")]
)
Expand All @@ -234,7 +234,7 @@ def test_century_millennium(engine: pl.GPUEngine, method, dtype):
assert_gpu_result_equal(q, engine=engine)


@pytest.mark.parametrize("method", ["century"])
@pytest.mark.parametrize("method", ["century", "millennium"])
@pytest.mark.parametrize(
"days",
[
Expand Down
Loading