DiadkoShmek opened a new issue, #55394:
URL: https://github.com/apache/arrow/issues/55394

   ### 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:
   
   ```python
   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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to