Implement more datetime polars.Expressions#23097
Conversation
Computes (year - 1) // divisor + 1 with a single transform.compute_column call instead of three separate binaryop kernels; casts the extracted INT16 year to INT32 up front to match polars' output type.
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds new temporal operations (Century, Millennium, Round, DaysInMonth, Quarter, Date) to cudf_polars' TemporalFunction expression evaluator, extends validation of bucket sizes for Truncate/Round, and adds corresponding parametrized GPU-vs-CPU tests for these operations. ChangesTemporal Function Extension
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
python/cudf_polars/tests/expressions/test_datetime_basic.py (2)
223-243: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated literal data list with
test_duration_total_component_extract.The 12-value duration list here is identical to the one in
test_duration_total_component_extracta few lines above (Lines 191-209). Consider hoisting it into a shared module-level constant or fixture to avoid duplication and keep both tests in sync if values change.♻️ Proposed refactor
+_DURATION_TEST_VALUES = [ + 0, + 1, + 15, + -1500, + 1000, + 1111, + 1500, + 11111, + -134234534, + 134234534, + 5857593848682946, + -5857593848682946, +] + def test_duration_total_component_extract(engine: pl.GPUEngine, field, dtype): ldf = pl.LazyFrame( { - "durations": pl.Series( - [ - 0, - 1, - ... - ], - dtype=dtype, - ), + "durations": pl.Series(_DURATION_TEST_VALUES, dtype=dtype), } )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/cudf_polars/tests/expressions/test_datetime_basic.py` around lines 223 - 243, The duration values used to build the LazyFrame in this test are duplicated in test_duration_total_component_extract, so centralize the shared list into a module-level constant or fixture and reuse it from both tests. Update the test setup around pl.LazyFrame and pl.Series to reference that shared source so the two duration component tests stay in sync if the data changes.
216-246: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing empty/single-element series coverage for new temporal ops.
The new tests for
total_*(fractional=True),century/millennium,dt.date(),days_in_month(), andquarter()includeNonevalues (all-null-element coverage) but none test an empty series or a single-element series, which the test guidelines call out explicitly.Consider adding at least one empty/single-element case per new operation (or a shared parametrized fixture) to close this gap.
Also applies to: 248-267, 287-305, 625-665
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/cudf_polars/tests/expressions/test_datetime_basic.py` around lines 216 - 246, The new temporal-op tests cover nulls but still miss empty and single-element series cases. Update the affected test groups around test_duration_total_component_extract_fractional and the related century/millennium, dt.date(), days_in_month(), and quarter() tests to add at least one empty-series and one single-value-series check, ideally via a shared parametrized helper/fixture so each new op is exercised through those edge cases.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@python/cudf_polars/tests/expressions/test_datetime_basic.py`:
- Around line 223-243: The duration values used to build the LazyFrame in this
test are duplicated in test_duration_total_component_extract, so centralize the
shared list into a module-level constant or fixture and reuse it from both
tests. Update the test setup around pl.LazyFrame and pl.Series to reference that
shared source so the two duration component tests stay in sync if the data
changes.
- Around line 216-246: The new temporal-op tests cover nulls but still miss
empty and single-element series cases. Update the affected test groups around
test_duration_total_component_extract_fractional and the related
century/millennium, dt.date(), days_in_month(), and quarter() tests to add at
least one empty-series and one single-value-series check, ideally via a shared
parametrized helper/fixture so each new op is exercised through those edge
cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: ef08a635-8dcd-4261-884c-6295f475d3a7
📒 Files selected for processing (2)
python/cudf_polars/cudf_polars/dsl/expressions/datetime.pypython/cudf_polars/tests/expressions/test_datetime_basic.py
|
Closing in favor of individual PRs |
Description
Implements the following datetime expressions
Expr.dt.centuryExpr.dt.millenniumExpr.dt.dateExpr.dt.days_in_monthExpr.dt.quarterExpr.dt.total_days/hours/minutes/seconds/milliseconds/microseconds/nanosecondsChecklist