Skip to content

[Python ] Table.to_batches() loses schema information when table has zero rows #49309

@alexowens90

Description

@alexowens90

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions