Skip to content

GH-45880: [C++][Python] Return TypeError for map parent indices - #52358

Open
skyon0522-ai wants to merge 1 commit into
apache:mainfrom
skyon0522-ai:codex/fix-map-parent-indices-crash
Open

skyon0522-ai wants to merge 1 commit into
apache:mainfrom
skyon0522-ai:codex/fix-map-parent-indices-crash

Conversation

@skyon0522-ai

@skyon0522-ai skyon0522-ai commented Oct 8, 2026 •

Copy link
Copy Markdown

Rationale for this change

MapArray.value_parent_indices() can terminate the Python process, as reported in #45880. MapType inherits ListType, so the list_parent_indices visitor falls through to Visit(const ListType&) and constructs a ListArray from MAP data. The internal type check then fails.

What changes are included in this PR?

Add an explicit MapType overload that delegates to the existing unsupported-input TypeError path. This preserves the kernel's current supported-input contract; it does not add parent-index computation for maps.

Add C++ regression coverage for a MapArray and a nonempty chunked map, plus Python coverage for the exposed method and the compute function.

Are these changes tested?

On Ubuntu 24.04 with Python 3.12.3, built C++ and editable PyArrow from c7944b3 with this patch:

  • TestVectorNested.*: 7 passed.
  • Related map and value_parent_indices Python tests: 9 passed, including the 4 focused value_parent_indices tests.
  • Seven additional checks on the identified fixed build passed, covering map errors, an equivalent list of structs, empty inputs, chunked inputs, and existing struct rejection.
  • Repository-pinned clang-format 18.1.8, configured flake8 6.1.0, and git diff --check passed.

The pre-fix termination was not re-executed locally. The diagnosis uses the original issue and maintainer reproduction, the current source path, and fixed-build regression results. The full Arrow suite and cross-platform CI were not run locally.

Are there any user-facing changes?

Calling the unsupported operation on a MapArray now raises ArrowTypeError, so Python callers can handle the error instead of losing the process. Existing supported list behavior and the zero-chunk path are preserved.

Was AI used for this PR?

AI tools assisted with source investigation, the code and tests, local validation, independent review, and this description. The submitting author reviewed the patch, confirmed that they understand and can investigate the changes, and accepts responsibility for the submission.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Closes #45880.

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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #45880 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] MapArray.value_parent_indices() crashes (probably segfaults)

1 participant