-
-
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(rust): Reject non-integral offset and length in AExpr::Slice #16874
Conversation
CodSpeed Performance ReportMerging #16874 will not alter performanceComparing Summary
|
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.
Signposts
py-polars/polars/expr/expr.py
Outdated
# This cast enables tail with expressions that return unsigned integers, | ||
# for which negate otherwise raises InvalidOperationError. | ||
offset = -self._from_pyexpr( | ||
parse_as_expression(n).cast(Int64, strict=False, wrap_numerical=True) | ||
) |
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.
This is arguably a "feature" improvement. Previously one could not ask for the tail
for an expression with an expression value of unsigned integer type. That is, this enables the following:
df.select(pl.col("a").tail(pl.lit(1, pl.UInt32()))
The casting is similar to the rust side implementation of tail:
/// Get the last `n` elements of the Expr result.
pub fn tail(self, length: Option<usize>) -> Self {
let len = length.unwrap_or(10);
self.slice(lit(-(len as i64)), lit(len as u64))
}
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16874 +/- ##
==========================================
- Coverage 81.10% 81.09% -0.02%
==========================================
Files 1435 1435
Lines 189546 189555 +9
Branches 2712 2712
==========================================
- Hits 153732 153719 -13
- Misses 35314 35336 +22
Partials 500 500 ☔ View full report in Codecov by Sentry. |
crates/polars-plan/src/logical_plan/conversion/type_coercion/mod.rs
Outdated
Show resolved
Hide resolved
crates/polars-plan/src/logical_plan/conversion/type_coercion/mod.rs
Outdated
Show resolved
Hide resolved
Ah.. Sorry for the inconvenience, but can you rebase? Seems to be some conflicts. |
Done. |
pl.Expr.slice
raise if the numeric arguments are not integral #16855