Fokko opened a new issue, #43183:
URL: https://github.com/apache/arrow/issues/43183
### Describe the bug, including details regarding any error messages,
version, and platform.
It looks like I'm able to cast ints/strings, but not date32:
```python
> import pyarrow as pa
> n_legs = pa.array([2, 2, 4, 4, 5, 100])
> animals = pa.array(["Flamingo", "Parrot", "Dog", "Horse", "Brittle stars",
"Centipede"])
> names = ["n_legs", "animals"]
> batch = pa.RecordBatch.from_arrays([n_legs, animals], names=names)
> batch
pyarrow.RecordBatch
n_legs: int64
animals: string
----
n_legs: [2,2,4,4,5,100]
animals: ["Flamingo","Parrot","Dog","Horse","Brittle stars","Centipede"]
> schema = pa.schema([
> ('n_legs', pa.int64()),
> ('animals', pa.string()),
> ])
> pa.RecordBatchReader.from_batches(
> schema,
> [batch]
> ).cast(schema).read_all()
pyarrow.Table
n_legs: int64
animals: string
----
n_legs: [[2,2,4,4,5,100]]
animals: [["Flamingo","Parrot","Dog","Horse","Brittle stars","Centipede"]]
```
But it seems to fail with a `date32`:
```python
> import pyarrow as pa
> from datetime import date
> birthday = [date(1990, 3, 1)]
> names = ["Fokko"]
> batch = pa.RecordBatch.from_arrays([birthday, names], names=['birthday',
'name'])
> batch
pyarrow.RecordBatch
birthday: date32[day]
name: string
----
birthday: [1990-03-01]
name: ["Fokko"]
> schema = pa.schema([
> ('birthday', pa.date32()),
> ('name', pa.string()),
> ])
> pa.RecordBatchReader.from_batches(
> schema,
> [batch]
> ).cast(schema).read_all()
---------------------------------------------------------------------------
ArrowTypeError Traceback (most recent call last)
Cell In[6], line 9
1 schema = pa.schema([
2 ('birthday', pa.date32()),
3 ('name', pa.string()),
4 ])
6 pa.RecordBatchReader.from_batches(
7 schema,
8 [batch]
----> 9 ).cast(schema).read_all()
File /opt/homebrew/lib/python3.10/site-packages/pyarrow/ipc.pxi:800, in
pyarrow.lib.RecordBatchReader.cast()
File /opt/homebrew/lib/python3.10/site-packages/pyarrow/error.pxi:154, in
pyarrow.lib.pyarrow_internal_check_status()
File /opt/homebrew/lib/python3.10/site-packages/pyarrow/error.pxi:91, in
pyarrow.lib.check_status()
ArrowTypeError: Field 0 cannot be cast from date32[day] to date32[day]
```
This looks like a valid cast operation to me. Please advise. Happy to create
a PR, if someone can point out the place where I should add the test would be
very helpful, since I'm not familiar with the codebase :)
### Component(s)
C++
--
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]