[Python ] Table.to_batches() loses schema information when table has zero rows
Open
Component: Python
Type: enhancement
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
Calling `to_batches` on a zero-row table returns an empty list, losing the schema information:
```
Python 3.13.5 (main, Jun 12 2025, 08:56:14) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyarrow as pa
>>> pa.__version__
'23.0.1'
>>> table = pa.table({"col": pa.array([], pa.int64())})
>>> table.to_batches()
[]
```
I would expect the result to be a single-element list, containing a `RecordBatch` with zero rows, and the same schema as the original table.
### Component(s)
Python
Contributor guide
Assessment
This issue has not been assessed yet.