Repository navigation
Report non-literal str.slice offsets accurately in cudf-polars - #24992
Conversation
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.
|
Thanks @WeAreResilience. Feel free to mark this as Ready for review when you want us to take a look. |
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
/ok to test 609b91e |
TomAugspurger
left a comment
There was a problem hiding this comment.
Looks good, thanks.
|
Pushed a small follow-up (52f81e2) narrowing the slice offsets to |
|
/ok to test 52f81e2 |
|
/ok to test 66f4bb2 |
|
/merge |
|
Thanks @WeAreResilience. |
|
Thanks @TomAugspurger for the review and for updating the branch. Glad to help, and happy to pick up more cudf-polars issues. |
Description
StringFunction.__init__incudf_polars/dsl/expressions/string.pyfolds the literal and float checks forstr.sliceinto one condition, so a column offset such aspl.lit("xh").str.slice(pl.col("c0"), 1)raisesSlice 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 raiseNotImplementedErrorduring 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_columnnow 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 checkandruff format(v0.15.22, the pre-commit pin) pass.Part of #24982
Checklist
Follow-up commit narrows the str.slice offsets to
Literalso mypy passes in check-style; no behavior change.