Skip to content

Implement more Polars string Expressions - #23095

Closed
mroeschke wants to merge 9 commits into
NVIDIA:mainfrom
mroeschke:cudf_polars/enh/5b_effort1_batch2
Closed

Implement more Polars string Expressions#23095
mroeschke wants to merge 9 commits into
NVIDIA:mainfrom
mroeschke:cudf_polars/enh/5b_effort1_batch2

Conversation

@mroeschke

Copy link
Copy Markdown
Contributor

Description

Implements the following string expressions

Expr.str.to_integer
Expr.str.count_matches(literal=True)
Expr.str.extract(group_index=0)
Expr.str.strptime/to_date/to_datetime(cache=True) (just ignores the cache=True keyword which I think is OK)
Expr.str.zfill w/ null widths

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke self-assigned this Jul 2, 2026
@mroeschke
mroeschke requested a review from a team as a code owner July 2, 2026 23:54
@mroeschke mroeschke added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 2, 2026
@mroeschke
mroeschke requested a review from madsbk July 2, 2026 23:54
@mroeschke mroeschke added the cudf-polars Issues specific to cudf-polars label Jul 2, 2026
@github-actions github-actions Bot added the Python Affects Python cuDF API. label Jul 2, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d06d7a7a-f452-4f5f-90f7-f26eb13e368e

📥 Commits

Reviewing files that changed from the base of the PR and between 199c51c and 6049894.

📒 Files selected for processing (1)
  • python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added GPU to_integer support with strict/non-strict parsing, consistent null handling, and supported base validation.
    • Extended string operations: count_matches(literal=...), extract(group_index=0), and zfill with per-row null widths.
    • Improved datetime parsing/inference, including stricter format-specifier validation and fractional-seconds precision detection.
  • Bug Fixes
    • Updated strptime validation to allow the cache option.
  • Tests
    • Expanded string-function test coverage (including strict failure cases) and adjusted expected failure/skip outcomes for known engine differences.

Walkthrough

This PR adds GPU support for str.to_integer, relaxes regex and string validation for literal matches and group_index=0, updates datetime parsing and inference handling, fixes null-width str.zfill, and revises GPU engine expected-failure mappings.

Changes

String Function Changes

Layer / File(s) Summary
ToInteger validation and evaluation
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Adds Name.ToInteger support, validates base==10 as a literal, implements parsing via is_integer/to_integers with strict-mode error handling and null masking, and adds tests for strict, non-strict, and unsupported-base cases.
CountMatches literal pattern support
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Escapes literal patterns during validation instead of rejecting them, and updates tests for multiple literal patterns and the empty-pattern unsupported case.
Extract group_index==0 support
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Wraps group_index==0 patterns in an outer capture group during validation, remaps the runtime group index during evaluation, and updates tests to treat group_index=0 as a success case.
Strptime cache and datetime inference
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Ignores the cache option in Strptime, validates datetime format specifiers, updates fractional-second inference regexes, and extends datetime format inference for fractional precision; tests cover default cache behavior and the translation-error condition.
ZFill null width handling
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Replaces null per-row widths with a placeholder during zfill computation, then reapplies a mask so rows with null widths remain null; adds a test for column null widths.
Streaming engine xfail mapping
python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py
Updates the GPU-engine expected-failure map for one Iceberg test and adds one streaming-engine expected-failure entry for a predicate pushdown test.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • rapidsai/cudf#22605: Also updates python/cudf_polars/cudf_polars/testing/inject_gpu_engine.py expected-failure and skip mappings.

Suggested labels: feature request

Suggested reviewers: Matt711, TomAugspurger

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change set: adding more Polars string expression support.
Description check ✅ Passed The description clearly lists the string expressions implemented and aligns with the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

mroeschke added 4 commits July 6, 2026 21:55
Reject datetime format specifiers libcudf cannot parse (e.g. %F, %#z,
%.f) at translation time so unsupported formats fall back to the CPU
engine instead of failing at runtime, and extend the format inference
patterns to cover no-seconds and fractional-second variants. Mark
test_predicate_pushdown_fallible_exprs_22284 as an expected streaming
failure since the error message differs from polars.
@mroeschke

Copy link
Copy Markdown
Contributor Author

Closing as these expressions will be split into individual PRs

@mroeschke mroeschke closed this Jul 7, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jul 7, 2026
@mroeschke
mroeschke deleted the cudf_polars/enh/5b_effort1_batch2 branch July 7, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants