Skip to content

GH-54637: [Python] add MemoryPool support to pq.read_table - #54919

Merged
AlenkaF merged 5 commits into
apache:mainfrom
omkar-334:GH-54637-parquet-read-table-memory-pool
Oct 28, 2026
Merged

AlenkaF merged 5 commits into
apache:mainfrom
omkar-334:GH-54637-parquet-read-table-memory-pool

Conversation

@omkar-334

@omkar-334 omkar-334 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

pq.read_table has no way to pass a memory pool. ParquetReader and Dataset.to_table already accept one, it just wasn't added.

What changes are included in this PR?

I added a memory_pool argument to read_table, ParquetFile and ParquetDataset. It is passed to ParquetReader and to Dataset.to_table, with docstrings updated.

Are these changes tested?

Yes. I added new tests in test_basic.py - It reads a Parquet file with a tracked memory pool and check that the pool was actually used. They cover read_table, ParquetFile and ParquetDataset.

Are there any user-facing changes?

New optional memory_pool keyword. No breaking changes.

Was AI used for this PR?

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI

Github Issue - #54637

Copilot AI balanced review requested due to automatic review settings October 21, 2026 22:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the awaiting review Awaiting review label Oct 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54637 has been automatically assigned in GitHub to PR creator.

@omkar-334

omkar-334 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

My understanding before implementing/opening the PR -

Function read_table supports 2 types of datasets

  1. dataset = ParquetDataset
  • self._dataset = ds.dataset
    This function returns multiple types, not so straightforward. The class Dataset (_dataset.pyx) has three types of datasets -

    classes = {
          'union': UnionDataset,
          'filesystem': FileSystemDataset,
          'in-memory': InMemoryDataset,
      }
    
    • _filesystem_dataset -> FileSystemDatasetFactory
    • _union_dataset -> UnionDataset
    • _in_memory_dataset -> InMemoryDataset
      We don;t need to change code for all the classes, the below unction makes it easy for us
  • table = self._dataset.to_table -> to_table (_dataset.pyx)
    This function in pyx supports MemoryPool -> we just need to edit this.

  1. dataset = ParquetFile
  • self.reader = ParquetReader()
    • python/pyarrow/_parquet.pyx - ParquetReader supports CMemoryPool* pool
  • self.reader.read_all
  • return dataset.read

@omkar-334

Copy link
Copy Markdown
Contributor Author
image Tests passing

@omkar-334

Copy link
Copy Markdown
Contributor Author

cc @pitrou

@pitrou pitrou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @omkar-334 . This looks good on the principle, just a small suggestion for improving tests.

Comment thread python/pyarrow/tests/parquet/test_basic.py Outdated
@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Oct 22, 2026
Copilot AI balanced review requested due to automatic review settings October 23, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@pitrou

pitrou commented Oct 26, 2026

Copy link
Copy Markdown
Member

Thanks a lot @omkar-334 ! @AlenkaF @jorisvandenbossche Do you want to give this a final review?

@AlenkaF AlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one question that doesn't necessarily need a code change, but I'm curious what you think @omkar-334.

Comment thread python/pyarrow/parquet/core.py Outdated
@omkar-334
omkar-334 force-pushed the GH-54637-parquet-read-table-memory-pool branch from 69c29d6 to 8b9af5d Compare October 28, 2026 06:22
Copilot AI balanced review requested due to automatic review settings October 28, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@omkar-334

Copy link
Copy Markdown
Contributor Author

@AlenkaF I've made the changes. The memory_pool input is as follows -

  • For ParquetFile - constructor takes the arg
  • For ParquetDataset - the read() method takes the arg

@AlenkaF AlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment on the read_table changes.

Comment thread python/pyarrow/parquet/core.py Outdated
Copilot AI balanced review requested due to automatic review settings October 28, 2026 06:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@AlenkaF

AlenkaF commented Oct 28, 2026

Copy link
Copy Markdown
Member

Thanks a lot @omkar-334!
I will wait for the CI and merge later today if the CI is green and there are no additional comments from other reviewers.

@AlenkaF
AlenkaF merged commit b8079cd into apache:main Oct 28, 2026
41 checks passed
@AlenkaF AlenkaF removed the awaiting committer review Awaiting committer review label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants