ketozhang commented on issue #43626:
URL: https://github.com/apache/arrow/issues/43626#issuecomment-2968225055
I tripped up in this thinking that `nullable=True` is the same as optional
columns.
```python
>>> import pyarrow as pa
>>>
>>> schema = pa.schema(
... [
... pa.field("id", pa.int64()),
... pa.field("nullable", pa.string(), nullable=True),
... ]
... )
>>>
>>> table = pa.Table.from_arrays(
... [pa.array([1, 2, 3], type=pa.int64())], names=["id"]
... )
>>>
>>> table.cast(schema)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyarrow/table.pxi", line 4717, in pyarrow.lib.Table.cast
ValueError: Target schema's field names are not matching the table's field
names: ['id'], ['id', 'nullable']
```
--
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]