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
[Python] pyarrow can read integers as dates in list but not np.array #55315
changed the title [-]`pyarrow` can read integers as dates in `list` but not `np.array`[/-][+][Python] `pyarrow` can read integers as dates in `list` but not `np.array`[/+]on Oct 29, 2026
I can reproduce this on pyarrow 26.0.0 / numpy 2.5.4. The two inputs go through different paths: a Python list is converted value by value, so plain ints are accepted for date32, while a numpy array is wrapped as int64 first and then cast to the requested type. The date32 cast only has an int32 -> date32 kernel (GetDate32Cast in cpp/src/arrow/compute/kernels/scalar_cast_temporal.cc), so pa.array([0, 1, 2]).cast("date32") fails with the same error. date64 does have int64 -> date64, which is why that one works from numpy.
Until that's added, either of these works with a numpy array:
Both give 1970-01-01, 1970-01-02, 1970-01-03. An int64 -> date32 cast with an overflow check (the list path already raises "Integer too large for date32" for 2**40) would probably make the two paths consistent.
I plan to investigate this issue and, if the source-level regression is confirmed, submit a focused fix with C++/Python regression coverage. I will first check for any existing work and validate the overflow behavior for integer-to-date32 casts.
Activity
[-]`pyarrow` can read integers as dates in `list` but not `np.array`[/-][+][Python] `pyarrow` can read integers as dates in `list` but not `np.array`[/+]mohamd764 commentedon Oct 29, 2026
I can reproduce this on pyarrow 26.0.0 / numpy 2.5.4. The two inputs go through different paths: a Python list is converted value by value, so plain ints are accepted for date32, while a numpy array is wrapped as int64 first and then cast to the requested type. The date32 cast only has an int32 -> date32 kernel (GetDate32Cast in cpp/src/arrow/compute/kernels/scalar_cast_temporal.cc), so
pa.array([0, 1, 2]).cast("date32")fails with the same error. date64 does have int64 -> date64, which is why that one works from numpy.Until that's added, either of these works with a numpy array:
Both give 1970-01-01, 1970-01-02, 1970-01-03. An int64 -> date32 cast with an overflow check (the list path already raises "Integer too large for date32" for 2**40) would probably make the two paths consistent.
Kodiologist commentedon Oct 30, 2026
It looks like casting smaller integer types (like
int16andint8) todate32also isn't supported.huong8373tt-beep commentedon Nov 1, 2026
I plan to investigate this issue and, if the source-level regression is confirmed, submit a focused fix with C++/Python regression coverage. I will first check for any existing work and validate the overflow behavior for integer-to-date32 casts.