Skip to content

[Python] Expose RecordBatchFileReader::CountRows in Python #49305

Closed

Description

@adrien-grl

Describe the enhancement requested

Problem / Motivation

In PyArrow, pyarrow.ipc.RecordBatchFileReader the only way I found to gather the total number of rows of contained in a Feather file is to do something along the lines of:

num_rows = sum(reader.get_batch(i).num_rows for i in range(reader.num_record_batches))

This is not very efficient when it seems you can directly count the rows using the metadata (as in RecordBatchFileReader::CountRows) (if I understand the code correctly?)

The current way of doing is intractable when reading from remote file systems.

Proposed solution

Expose RecordBatchFileReader::CountRows in Python.

References

virtual Result<int64_t> CountRows() = 0;

Thank you for reading my suggestion and all the amazing work!!

Component(s)

Python

Activity

  1. AlenkaF commented on Mar 27, 2026

    @AlenkaF
    Member

    Thank you for opening the issue @adrien-grl !
    From a quick look of the code I would agree. This would be nice to have in PyArrow and looks like a straightforward binding to add with all the info in the above description already figuring out important steps.

    Would you be interested in submitting a PR?

  2. GujaLomsadze commented on Jul 26, 2026

    @GujaLomsadze
    Contributor

    Hi @AlenkaF, @adrien-grl.
    Seems like this issue has been stale for quite a bit. I would love to take this.

  3. added a commit that references this issue on Jul 30, 2026
  4. added this to the 26.0.0 milestone on Jul 30, 2026
  5. pitrou commented on Jul 30, 2026

    @pitrou
    Member

    Issue resolved by pull request 50646
    #50646

  6. added a commit that references this issue on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions