Skip to content

GH-51223: [C++] Fix copying sliced boolean arrays - #51240

Open
A-makarim wants to merge 1 commit into
apache:mainfrom
A-makarim:GH-51223-fix-sliced-boolean-arrays
Open

GH-51223: [C++] Fix copying sliced boolean arrays#51240
A-makarim wants to merge 1 commit into
apache:mainfrom
A-makarim:GH-51223-fix-sliced-boolean-arrays

Conversation

@A-makarim

Copy link
Copy Markdown

Rationale for this change

Boolean values are bit-packed. When copying values from a sliced boolean array,
the copy path did not include the array's slice offset. This caused
fill_null_forward, fill_null_backward, and replace_with_mask to read
values from earlier positions in the parent array.

What changes are included in this PR?

  • Apply ArraySpan::offset to the bit index when copying boolean values from
    an ArraySpan.
  • Add regression coverage for sliced boolean inputs in replace_with_mask,
    fill_null_forward, and fill_null_backward.

Are these changes tested?

Yes. I ran arrow-compute-vector-test locally.

Are there any user-facing changes?

Only a bugfix.

This PR contains a "Critical Fix".

This fixes a bug that caused compute operations on sliced boolean arrays with
a non-zero offset to produce incorrect values.

Fixes apache#51223

Signed-off-by: Abdul Azeem Makarim <114302821+A-makarim@users.noreply.github.com>
@A-makarim
A-makarim requested a review from pitrou as a code owner September 8, 2026 16:17
Copilot AI lite review requested due to automatic review settings September 8, 2026 16:17
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #51223 has no components, please add labels for components.

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.

🟢 Approval recommended

The boolean ArraySpan copy now correctly accounts for slice offsets and the added regression tests directly cover the reported failure modes.

Pull request overview

Fixes incorrect bit indexing when copying from sliced boolean ArraySpans by ensuring the slice offset is applied during bitmap copies, and adds regression tests covering the affected compute kernels.

Changes:

  • Apply ArraySpan::offset to the bit index when copying boolean values via CopyDataUtils<BooleanType>.
  • Add regression tests for sliced boolean inputs in replace_with_mask, fill_null_forward, and fill_null_backward.
File summaries
File Description
cpp/src/arrow/compute/kernels/copy_data_internal.h Fix boolean ArraySpan copy to include in.offset in the bit index passed to CopyBitmap.
cpp/src/arrow/compute/kernels/vector_replace_test.cc Add regression tests that exercise non-byte-aligned (offset=3) sliced boolean arrays for replace_with_mask and fill-null kernels.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

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