Skip to content

[Python] pyarrow.compute.subtract_checked overflowing for some duration arrays constructed from numpy #35088

Open
@lukemanley

Description

@lukemanley

Describe the bug, including details regarding any error messages, version, and platform.

In the example below, arr2 and arr3 are duration arrays with a single null element.

arr2 is constructed from a list
arr3 is constructed from a numpy array

Once constructed, they evaluate to being equal.

However, they exhibit different behavior once passed to pyarrow.compute.subtract_checked:

import pyarrow as pa
import pyarrow.compute as pc
import numpy as np

data1 = [86400000000]
data2 = [None]
data3 = np.array([None], dtype="timedelta64[ns]")

arr1 = pa.array(data1, type=pa.duration("ns"))
arr2 = pa.array(data2, type=pa.duration("ns"))
arr3 = pa.array(data3, type=pa.duration("ns"))

assert arr2 == arr3

pc.subtract_checked(arr1, arr2)  # ok
pc.subtract_checked(arr1, arr3)  # ArrowInvalid: overflow 

Component(s)

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions