[C++][Compute] negate_checked silently wraps duration overflow
Describe the bug
negate_checked silently wraps for the minimum valid duration value instead of returning the documented overflow error. Reproduced with PyArrow 26.0.1 on Linux x86-64:
import pyarrow as pa
import pyarrow.compute as pc
minimum = -(1 << 63)
a = pa.array([minimum], type=pa.duration("ns"))
assert a[0].is_valid and a.null_count == 0
pc.negate_checked(a).cast(pa.int64()).to_pylist()
# [-9223372036854775808]
pc.negate_checked(pa.array([minimum], type=pa.int64()))
# ArrowInvalid: overflow
The same duration result occurs for s, ms, us and ns, including valid scalars. Negating this value requires 9223372036854775808, which the duration's signed int64 storage cannot represent. It should raise an overflow error; the ordinary unchecked negate wrapping behavior can remain unchanged.
Current main 690ed5665832e10358618614e506c590f2a61bf9, cpp/src/arrow/compute/kernels/scalar_arithmetic.cc:1815-1820, registers duration kernels under negate_checked with ArithmeticExec<ScalarUnaryNotNull, Negate>. The existing NegateChecked helper is used for the other checked numeric negations.
Component(s)
C++, Python
AI assistance was used for investigation and local verification.