Styxis
Company
Knowledge

Checking the int64 minimum before negating Arrow durations

The smallest signed duration has no positive counterpart in the same storage type.

The signed range is asymmetric

Even a function named checked needs an input boundary for the asymmetric signed minimum. The most negative int64 value cannot be negated into a representable positive int64. Preserve the duration unit while inspecting raw ticks so that this specific input can be isolated before arithmetic. [1, 2, 3]

Different results for duration and integer controls

The PyArrow 26.0.1 report applies negate_checked to a valid minimum duration and receives the same negative value. Its ordinary int64 control raises overflow. The reporter describes the duration result across seconds, milliseconds, microseconds and nanoseconds; this article does not claim a separate execution of those kernels. [1]

Distinguish missingness from a valid minimum

Preserve duration units and quarantine the unrepresentable minimum before forwarding values for negation. Retain validity together with raw_ticks so that a missing-value sentinel is not mistaken for a valid measurement. Changing units as a workaround changes both range and precision and requires its own contract. [1, 3]

Two boundary values as an illustrative control

Set the allowed lower bound for negation to -9223372036854775807 ticks. That value passes. The next smaller value, -9223372036854775808, would require positive 9223372036854775808 and fails because signed int64 cannot represent it. Truthound Core's BetweenValidator can apply this lower bound to a prepared integer-tick column. This filters an input condition; it neither repairs the duration kernel nor prevents every later arithmetic overflow. [1, 2, 3]

Application conditions

Prepare duration_unit, raw_ticks and allowed_minimum_ticks from original data or an independent control, aligned to the same run, file and key scope.

Alternatives

Use a separate arithmetic path that reports an unrepresentable negation as an error.

Limitations

  • A range check does not repair the duration arithmetic kernel. Distinguish missing-value sentinels from a valid minimum value.

Evidence

Event checked
Subject checked
Modified