mohamd764 commented on issue #55315:
URL: https://github.com/apache/arrow/issues/55315#issuecomment-6504796059
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:
```python
pa.array(np.array([0, 1, 2], dtype="int32"), type="date32")
pa.array(np.array([0, 1, 2]).astype("datetime64[D]"))
```
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.
--
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]