Skip to content

Python bindings for Parquet select cols by field ID - #22956

Merged
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
mhaseeb123:fea/py-bindings-select-cols-by-field-id
Jul 20, 2026
Merged

Python bindings for Parquet select cols by field ID#22956
rapids-bot[bot] merged 8 commits into
NVIDIA:mainfrom
mhaseeb123:fea/py-bindings-select-cols-by-field-id

Conversation

@mhaseeb123

Copy link
Copy Markdown
Contributor

Description

Follow up ##22955

This PR adds python bindings for Parquet column selection by field ID

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. pylibcudf Issues specific to the pylibcudf package labels Jun 24, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jul 20, 2026
@mhaseeb123
mhaseeb123 marked this pull request as ready for review July 20, 2026 17:33
@mhaseeb123
mhaseeb123 requested a review from a team as a code owner July 20, 2026 17:33
@mhaseeb123
mhaseeb123 requested review from Matt711 and mroeschke July 20, 2026 17:33
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c7b05969-0ae1-4f71-96f3-d79844bc3598

📥 Commits

Reviewing files that changed from the base of the PR and between ce63c86 and ceb4296.

📒 Files selected for processing (4)
  • python/pylibcudf/pylibcudf/io/parquet.pxd
  • python/pylibcudf/pylibcudf/io/parquet.pyi
  • python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd
  • python/pylibcudf/tests/io/test_parquet.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • python/pylibcudf/pylibcudf/io/parquet.pxd
  • python/pylibcudf/tests/io/test_parquet.py
  • python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd
  • python/pylibcudf/pylibcudf/io/parquet.pyi

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for selecting Parquet columns by field ID when reading data.
    • Added field-ID options to both direct reader configuration and the fluent builder API.
    • Field-ID selections preserve the requested column order.
  • Bug Fixes

    • Corrected column-index parameter documentation to accurately describe index-based selection.
  • Tests

    • Added coverage validating Parquet field-ID column selection and ordering.

Walkthrough

The Parquet Python bindings add reader option and builder support for selecting columns by field IDs, forward IDs as int32_t vectors to libcudf, correct related parameter documentation, and add coverage using explicit Parquet field-ID metadata.

Changes

Parquet field-ID projection

Layer / File(s) Summary
Field-ID option contracts
python/pylibcudf/pylibcudf/io/parquet.pxd, python/pylibcudf/pylibcudf/io/parquet.pyi, python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd
Parquet reader options and builders expose typed column_field_ids setters backed by vector[int32_t]; builder projection methods are declared as fluent APIs.
Cython field-ID wiring
python/pylibcudf/pylibcudf/io/parquet.pyx
Python field-ID lists are converted to int32_t vectors and forwarded to the reader options and builder; related column_indices documentation is corrected.
Field-ID projection test
python/pylibcudf/tests/io/test_parquet.py
A test verifies field-ID-based column selection and ordering against Parquet schema metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • rapidsai/cudf#22955: Adds the corresponding C++ Parquet field-ID option and reader projection logic.

Suggested reviewers: mroeschke

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Python bindings for Parquet column selection by field ID.
Description check ✅ Passed The description matches the PR and mentions the Python bindings, tests, and documentation updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
python/pylibcudf/tests/io/test_parquet.py (1)

109-155: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding edge case tests for field-ID selection.

The test covers the happy path well, but per coding guidelines, test files should provide comprehensive edge case coverage. Consider adding cases for: empty field-ID list, single field-ID, non-existent field-ID (error handling), and duplicate field-IDs.

As per coding guidelines: "Ensure test files provide comprehensive edge case coverage (empty, all-null, single-element, mixed types) and do not depend on external datasets."

🧪 Suggested edge case tests
 def test_read_parquet_column_field_ids(binary_source_or_sink):
     # ... existing test ...

+def test_read_parquet_column_field_ids_single(binary_source_or_sink):
+    schema = pa.schema([
+        pa.field("col_int64", pa.int64(), metadata={b"PARQUET:field_id": b"10"}),
+        pa.field("col_string", pa.string(), metadata={b"PARQUET:field_id": b"20"}),
+    ])
+    pa_table = pa.Table.from_arrays(
+        [
+            pa.array([1, 2, 3], type=pa.int64()),
+            pa.array(["a", "b", "c"], type=pa.string()),
+        ],
+        schema=schema,
+    )
+    source = make_source(
+        binary_source_or_sink, pa_table, **_COMMON_PARQUET_SOURCE_KWARGS
+    )
+    source_info = plc.io.SourceInfo([source])
+    options = (
+        plc.io.parquet.ParquetReaderOptions.builder(source_info)
+        .column_field_ids([20])
+        .build()
+    )
+    res = plc.io.parquet.read_parquet(options)
+    assert_table_and_meta_eq(
+        pa_table.select(["col_string"]),
+        res,
+        check_field_nullability=False,
+    )
+
+def test_read_parquet_column_field_ids_empty(binary_source_or_sink):
+    schema = pa.schema([
+        pa.field("col_int64", pa.int64(), metadata={b"PARQUET:field_id": b"10"}),
+    ])
+    pa_table = pa.Table.from_arrays(
+        [pa.array([1, 2, 3], type=pa.int64())],
+        schema=schema,
+    )
+    source = make_source(
+        binary_source_or_sink, pa_table, **_COMMON_PARQUET_SOURCE_KWARGS
+    )
+    source_info = plc.io.SourceInfo([source])
+    options = (
+        plc.io.parquet.ParquetReaderOptions.builder(source_info)
+        .column_field_ids([])
+        .build()
+    )
+    res = plc.io.parquet.read_parquet(options)
+    # Assert behavior for empty field-ID list (all columns or no columns)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/pylibcudf/tests/io/test_parquet.py` around lines 109 - 155, Extend
test_read_parquet_column_field_ids with edge-case coverage for an empty field-ID
list, a single field ID, duplicate field IDs, and a non-existent field ID that
verifies the expected error. Reuse the existing in-memory schema, source, and
reader-options setup, and assert the resulting column selection or error
behavior for each case without introducing external datasets.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@python/pylibcudf/tests/io/test_parquet.py`:
- Around line 109-155: Extend test_read_parquet_column_field_ids with edge-case
coverage for an empty field-ID list, a single field ID, duplicate field IDs, and
a non-existent field ID that verifies the expected error. Reuse the existing
in-memory schema, source, and reader-options setup, and assert the resulting
column selection or error behavior for each case without introducing external
datasets.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ee9f198a-fd6b-4f36-a64a-cf3f321ccedc

📥 Commits

Reviewing files that changed from the base of the PR and between 1995350 and ce63c86.

📒 Files selected for processing (5)
  • python/pylibcudf/pylibcudf/io/parquet.pxd
  • python/pylibcudf/pylibcudf/io/parquet.pyi
  • python/pylibcudf/pylibcudf/io/parquet.pyx
  • python/pylibcudf/pylibcudf/libcudf/io/parquet.pxd
  • python/pylibcudf/tests/io/test_parquet.py

@mhaseeb123 mhaseeb123 added 4 - Needs Review Waiting for reviewer to review or respond non-breaking Non-breaking change feature request New feature or request labels Jul 20, 2026
@mhaseeb123

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 4c49b9b into NVIDIA:main Jul 20, 2026
129 of 130 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jul 20, 2026
@mhaseeb123
mhaseeb123 deleted the fea/py-bindings-select-cols-by-field-id branch July 20, 2026 23:35
@mhaseeb123 mhaseeb123 removed the 4 - Needs Review Waiting for reviewer to review or respond label Jul 20, 2026
@mhaseeb123 mhaseeb123 added the 5 - Ready to Merge Testing and reviews complete, ready to merge label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to Merge Testing and reviews complete, ready to merge feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants