Skip to content

GH-50879: [C++] Implement replace_with_mask for List and LargeList types - #50880

Open
pratyushadk wants to merge 2 commits into
apache:mainfrom
pratyushadk:replace-with-mask-list-types
Open

GH-50879: [C++] Implement replace_with_mask for List and LargeList types#50880
pratyushadk wants to merge 2 commits into
apache:mainfrom
pratyushadk:replace-with-mask-list-types

Conversation

@pratyushadk

@pratyushadk pratyushadk commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Currently, the replace_with_mask compute kernel throws a NotImplemented error when called on variable-width list arrays (ListType and LargeListType). Given that this function is widely used for data manipulation, supporting list arrays natively is a highly requested enhancement.

What changes are included in this PR?

This PR introduces variable-width list support to the replace_with_mask kernel.

  • Modified the primary ReplaceMaskImpl template condition to exclude variable-length list types to resolve MSVC compilation ambiguities.
  • Implemented a specialized ReplaceMaskImpl for ListType and LargeListType. It safely iterates through values and uses ListBuilder / LargeListBuilder to append array slices of the child arrays, handling nulls without directly mutating array offsets.
  • Registered the List and LargeList types to the replace_with_mask function registry (excluding fill_null functions which do not yet support lists).

Are these changes tested?

Yes. Extensive C++ unit tests were added in vector_replace_test.cc for both ListType and LargeListType. The test suites cover scalar vs. array masks, null mask entries, empty lists, mismatched replacement lengths, and chunked arrays. All tests pass locally on Windows MSVC.

Are there any user-facing changes?

Yes. Users can now pass ListArray and LargeListArray types to replace_with_mask without encountering a NotImplemented error. There are no breaking changes to existing public APIs.

…ist types

This commit adds support for variable-width list types (ListType and LargeListType) to the replace_with_mask compute kernel. It introduces a specialization of ReplaceMaskImpl that handles variable-length children safely by directly iterating over values and appending array slices, avoiding invalid length mutations.
Copilot AI lite review requested due to automatic review settings August 15, 2026 20:39
@pratyushadk
pratyushadk requested a review from pitrou as a code owner August 15, 2026 20:39
@github-actions

Copy link
Copy Markdown

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

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.

Pull request overview

This PR extends the replace_with_mask compute kernel to support variable-width list arrays (ListType and LargeListType) in Arrow C++. It adds a dedicated ReplaceMaskImpl specialization for list types that builds output via list builders (avoiding unsafe direct offset mutation) and registers the new list kernels specifically for replace_with_mask while keeping fill_null_forward/backward registrations list-free.

Changes:

  • Added a ReplaceMaskImpl specialization for ListType / LargeListType using ListBuilder / LargeListBuilder and AppendArraySlice to copy list elements safely.
  • Adjusted the primary ReplaceMaskImpl SFINAE condition to exclude variable-length list types, preventing template ambiguity on MSVC.
  • Registered LIST and LARGE_LIST kernels for replace_with_mask only, and added new unit tests covering list/large_list scenarios (including chunked inputs).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cpp/src/arrow/compute/kernels/vector_replace.cc Adds list/large_list kernel implementation + registration adjustments to enable replace_with_mask on variable-width list types.
cpp/src/arrow/compute/kernels/vector_replace_test.cc Adds C++ unit tests validating replace_with_mask behavior for list<int32> and large_list<int32> (scalar/array masks, nulls, chunked, mismatch cases).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 16, 2026 03:51

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@pratyushadk

Copy link
Copy Markdown
Contributor Author

The Dev / Lint failure was a clang-format alignment issue which has been fixed in the latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants