You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
date_trunc panics (remainder with a divisor of zero) for intervals finer than the timestamp's time unit #7713
The first two calls panic with attempt to calculate the remainder with a divisor of zero.
The third returns ...56.049012: it truncated to a 2 µs grid instead of 2500 ns.
Expected:
1 nanosecond on a microsecond column: a no-op, since every value is already on that grid.
0 days: a ValueError instead of a panic.
2500 nanoseconds: ...56.049010, the epoch-aligned 2500 ns grid. Alternatively an error saying the interval isn't representable in the column's unit, rather than a silently different interval.
Cause: process_interval converts the interval into the column's time unit with num_microseconds() / num_seconds() etc., which truncates. Any interval finer than the unit becomes 0, and truncate then computes ts % 0. A zero-length interval reaches the same % 0.
Suggested fix: reject non-positive intervals with a ValueError, and compute the truncation in a unit fine enough for the interval (or error when the interval isn't a whole multiple of the column's unit).
Activity