-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix slice
length no longer allowing None
#17372
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17372 +/- ##
==========================================
+ Coverage 80.72% 80.74% +0.02%
==========================================
Files 1475 1475
Lines 193383 193383
Branches 2760 2760
==========================================
+ Hits 156113 156154 +41
+ Misses 36760 36719 -41
Partials 510 510 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! Looks correct to me.
None
None
slice
length no longer allowing None
@@ -451,7 +451,7 @@ impl OptimizationRule for TypeCoercionRule { | |||
polars_ensure!(offset_dtype.is_integer(), InvalidOperation: "offset must be integral for slice, not {}", offset_dtype); | |||
let (_, length_dtype) = | |||
unpack!(get_aexpr_and_type(expr_arena, length, &input_schema)); | |||
polars_ensure!(length_dtype.is_integer(), InvalidOperation: "length must be integral for slice, not {}", length_dtype); | |||
polars_ensure!(length_dtype.is_integer() || length_dtype.is_null(), InvalidOperation: "length must be integral for slice, not {}", length_dtype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should negate the check. !is_null
.
@@ -747,3 +747,16 @@ def test_slice_rejects_non_integral() -> None: | |||
|
|||
with pytest.raises(pl.exceptions.InvalidOperationError): | |||
df.select(pl.col("a").slice(pl.lit("1"), None)).collect() | |||
|
|||
|
|||
def test_slice() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test what you want fixed? E.g. ensure that we raise on the invalid input.
Ah, nevermind. I now see the issue. We want |
Fixes #17365