Skip to content

Report non-literal str.slice offsets accurately in cudf-polars - #24992

Merged
rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
WeAreResilience:fix/24982-slice-offset-message
Nov 3, 2026
Merged

rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
WeAreResilience:fix/24982-slice-offset-message

Conversation

@WeAreResilience

@WeAreResilience WeAreResilience commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

StringFunction.__init__ in cudf_polars/dsl/expressions/string.py folds the literal and float checks for str.slice into one condition, so a column offset such as pl.lit("xh").str.slice(pl.col("c0"), 1) raises Slice does not support float literal start and stop values, although nothing about it is a float.

This splits the check: non-literal start/length arguments now raise Slice only supports literal start and stop values (the wording cudf-polars 26.10 used before the float check was added), and float literals keep their existing message. Both still raise NotImplementedError during translation, so CPU fallback is unchanged. Per-row offsets would need a libcudf slice that takes column starts and stops, which is out of scope here, so this is Part of #24982 rather than a fix for the feature request.

Testing: test_slice_column now also asserts the translator error names literal start and stop values. I don't have a GPU, so I could not run the test suite locally and am relying on CI. ruff check and ruff format (v0.15.22, the pre-commit pin) pass.

Part of #24982

Checklist

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

Follow-up commit narrows the str.slice offsets to Literal so mypy passes in check-style; no behavior change.

A column offset or length failed the float-literal check and raised
'Slice does not support float literal start and stop values'. Check for
non-literal arguments first so the message says what is unsupported.
@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Nov 2, 2026
@TomAugspurger

Copy link
Copy Markdown
Contributor

Thanks @WeAreResilience. Feel free to mark this as Ready for review when you want us to take a look.

@TomAugspurger TomAugspurger added bug Something isn't working non-breaking Non-breaking change labels Nov 2, 2026
@WeAreResilience
WeAreResilience marked this pull request as ready for review November 2, 2026 20:20
@WeAreResilience
WeAreResilience requested a review from a team as a code owner November 2, 2026 20:20
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • String slicing now reports a literal-only error when the start or stop value is not a literal, and retains the float-specific error for floating-point literal values. Column-based string slicing remains unsupported.
    • Error messages now distinguish between unsupported non-literal values and floating-point literal values, making it clearer why a string-slice expression cannot be translated.

String slice validation now reports a dedicated error when start or stop is not a literal. Float literals retain the existing float-specific error. The test checks the translator’s recorded error for column-based bounds.

Changes: String slice validation

Layer / File(s) Summary
Slice bound validation and test
python/cudf_polars/cudf_polars/dsl/expressions/string.py, python/cudf_polars/tests/expressions/test_stringfunction.py
Validation reports a dedicated error for non-literal start or stop values and retains the float-specific error. The test checks the translator’s recorded error for column-based slices.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

Suggested reviewers: matt711

Merge Risk: Minimal · up to 66f4b

The change narrowly improves string-slice validation messages, with no identified merge-blocking behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: correcting reporting for non-literal string-slice offsets in cudf-polars.
Description check Passed The description directly explains the incorrect error message, the new validation behavior, unchanged float handling, test coverage, and scope limitations.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: NVIDIA/cudf
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 170dd43
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 059dbce9-6f7e-45ce-b789-1bd161277dde
Commits

Reviewing files that changed from the base of the PR and between 52f81e2 and 66f4bb2.

Files selected for processing: 2
  • python/cudf_polars/cudf_polars/dsl/expressions/string.py
  • python/cudf_polars/tests/expressions/test_stringfunction.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@TomAugspurger

Copy link
Copy Markdown
Contributor

/ok to test 609b91e

@TomAugspurger TomAugspurger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

@WeAreResilience

Copy link
Copy Markdown
Contributor Author

Pushed a small follow-up (52f81e2) narrowing the slice offsets to Literal to satisfy mypy. Could you re-run /ok to test when you have a moment?

@TomAugspurger

Copy link
Copy Markdown
Contributor

/ok to test 52f81e2

@TomAugspurger

Copy link
Copy Markdown
Contributor

/ok to test 66f4bb2

@TomAugspurger

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 4e52d4b into NVIDIA:main Nov 3, 2026
89 checks passed
@TomAugspurger

Copy link
Copy Markdown
Contributor

Thanks @WeAreResilience.

@github-project-automation github-project-automation Bot moved this from Todo to Done in cuDF Python Nov 3, 2026
@WeAreResilience

Copy link
Copy Markdown
Contributor Author

Thanks @TomAugspurger for the review and for updating the branch. Glad to help, and happy to pick up more cudf-polars issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cudf-polars Issues specific to cudf-polars non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants