dt.total_nanoseconds
and dt.total_microseconds
may overflow silently
#16057
Labels
A-timeseries
Area: date/time functionality
bug
Something isn't working
P-low
Priority: low
python
Related to Python Polars
Checks
Reproducible example
Log output
shape: (1,) Series: '' [i64] [ -9223371273709551616 ]
Issue description
The Series has time unit
us
. Getting the total number of nanoseconds requires multiplying the underlying integer by 1000, which may overflow.We currently use unchecked multiplication for this, while we would need to use checked multiplication and set any overflowing values to
null
. The fix would be to implement checked arithmetic kernels and use these here.The offending code is here:
polars/crates/polars-time/src/chunkedarray/duration.rs
Lines 100 to 108 in eb7f939
Expected behavior
Output should be null rather than wrapping.
Installed versions
main
The text was updated successfully, but these errors were encountered: