Skip to content

GH-55326: [C++][Python] Preserve field identity in ORC Dataset scans - #55350

Open
jiangxt2 wants to merge 2 commits into
apache:mainfrom
jiangxt2:orc-dataset-field-identity
Open

jiangxt2 wants to merge 2 commits into
apache:mainfrom
jiangxt2:orc-dataset-field-identity

Conversation

@jiangxt2

@jiangxt2 jiangxt2 commented Oct 31, 2026 •

Copy link
Copy Markdown

Rationale for this change

ORC Dataset scans can confuse a literal top-level field such as a.b with the nested path a / b. This can replace stored values with nulls and cause filters to discard matching rows.

Fixes #55326.

What changes are included in this PR?

  • Resolve materialized field references against the Dataset schema before mapping them to per-file physical top-level indices. Preserve positional references when the schemas match, and keep each name component separate when mapping across schemas.
  • Add GetRecordBatchReaderByIndices, reusing integer selection and streaming reader construction while preserving the existing name-based API and its empty-initializer-list calls.
  • Add adapter and Dataset regressions covering colliding field paths, positional projection and filtering, filter-only dependencies, reordered and missing fields, and positional projections with duplicate names when schemas match. Adapter tests also check reader schemas and field metadata for nonempty and empty files, index selection, batch boundaries, and multiple stripes.

Are these changes tested?

Validated with matching C++ and Python builds on macOS arm64, using CPython 3.13.7 and liborc 2.2.1.

  • cpp/build/dev/release/arrow-orc-adapter-test: 41 passed; one existing timezone-database check is skipped because it applies only to ORC versions before 2.0.
  • cpp/build/dev/release/arrow-dataset-file-orc-test: 27 passed.
  • The following complete Python ORC collection: 49 passed, no skips.
python -m pytest -q -ra --enable-orc --enable-dataset --enable-pandas --enable-snappy \
  python/pyarrow/tests/test_orc.py \
  python/pyarrow/tests/test_dataset.py::test_orc_format \
  python/pyarrow/tests/test_dataset.py::test_orc_dotted_field_identity \
  python/pyarrow/tests/test_dataset.py::test_orc_positional_field_identity \
  python/pyarrow/tests/test_dataset.py::test_orc_duplicate_field_positional_projection \
  python/pyarrow/tests/test_dataset.py::test_orc_dotted_field_schema_evolution \
  python/pyarrow/tests/test_dataset.py::test_orc_scan_options \
  python/pyarrow/tests/test_dataset.py::test_orc_format_not_supported \
  python/pyarrow/tests/test_dataset.py::test_orc_writer_not_implemented_for_dataset

clang-format, cpplint, autopep8, Flake8, and git diff --check passed.

Are there any user-facing changes?

ORC Dataset full scans, projections, and filters preserve the correct fields when literal dotted names collide with nested paths, including positional references and reordered file schemas. Existing name-based ORCFile selector semantics are preserved.

This PR contains a "Critical Fix". It corrects silent null substitution and dropped rows in query results.

Was AI used for this PR?

Codex generated the code, tests, and PR description and performed local review and verification.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

…scans

Pass per-file top-level field indices to the ORC batch reader so literal
dotted names cannot be confused with nested paths. Preserve the existing
name-based API and add adapter and Dataset regression coverage.

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@github-actions

Copy link
Copy Markdown

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

…C scans

Resolve materialized references against the Dataset schema before mapping
them to per-file fields. Preserve positional identity for matching schemas
and add projection, filter, and reader-schema regression coverage.

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@jiangxt2
jiangxt2 marked this pull request as ready for review November 4, 2026 04:19
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.

[C++][Python][Dataset][ORC] Dataset scans return nulls when a dotted field name collides with a nested path

1 participant