Skip to content

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

Draft
jiangxt2 wants to merge 1 commit into
apache:mainfrom
jiangxt2:orc-dataset-field-identity
Draft

jiangxt2 wants to merge 1 commit 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?

  • Pass per-file physical top-level field indices from Dataset to the ORC batch reader.
  • 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, projection and filter dependencies, field reordering, missing columns, batch boundaries, empty inputs, and memory-backed and on-disk files.

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: 39 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_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, regardless of field order. 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.

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