Misleading error message when casting
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
This is really a minor issue.
The error message when casting a table with mismatching column name is misleading.
```python
import pyarrow as pa
pa.table({"col1": ["abc"]}).cast(
pa.schema([("col1", pa.string()), ("col2", pa.string())])
)
```
Throws:
```
ValueError: Target schema's field names are not matching the table's field names: ['col1'], ['col1', 'col2']
```
You'd expect the first list of field names to be the "Target schema's field names" and the second one to be "the table's field names", given how it is worded.
Alternatively if we want to keep the order, we can change the wording to "Table's field names are not matching the target schema's field names"
The later makes more sense to me because we are calling table.cast(schema), so the table comes first in the expression.
It would need fixing in a few places. Happy to send an MR.
https://github.com/apache/arrow/blob/802a84693b21847fc48efa2b29e23e0058256eeb/python/pyarrow/tests/test_table.py#L2109
https://github.com/apache/arrow/blob/802a84693b21847fc48efa2b29e23e0058256eeb/python/pyarrow/ipc.pxi#L800
https://github.com/apache/arrow/blob/802a84693b21847fc48efa2b29e23e0058256eeb/python/pyarrow/table.pxi#L3308
### Component(s)
Python
Contributor guide
Assessment
This issue has not been assessed yet.