You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "A-makarim (via GitHub)" <gi...@apache.org> on 2026/09/08 16:17:41 UTC

[PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

A-makarim opened a new pull request, #51240:
URL: https://github.com/apache/arrow/pull/51240

   ### 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.
   
   * GitHub Issue: #51223
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #51240:
URL: https://github.com/apache/arrow/pull/51240#discussion_r4039324608


##########
cpp/src/arrow/compute/kernels/copy_data_internal.h:
##########


Review Comment:
   Is this one ever called directly without accounting for the input offset?
   If so, then we must fix those use cases as well. Otherwise, perhaps make this method protected to avoid external usage?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #51240:
URL: https://github.com/apache/arrow/pull/51240#issuecomment-5588339517

   :warning: GitHub issue #51223 **has no components**, please add labels for components.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #51240:
URL: https://github.com/apache/arrow/pull/51240


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "A-makarim (via GitHub)" <gi...@apache.org>.
A-makarim commented on code in PR #51240:
URL: https://github.com/apache/arrow/pull/51240#discussion_r4045645660


##########
cpp/src/arrow/compute/kernels/copy_data_internal.h:
##########


Review Comment:
   Yes, I checked the direct uses of the `uint8_t*` overload. They already pass an absolute bit offset, including the source `ArraySpan::offset` (for example, `CopyValues` in `scalar_if_else.cc` passes `array.offset + in_offset`).
   
   The affected callers use the `ArraySpan` overload and pass an offset relative to that span, so adding `in.offset` there matches the fixed-width specializations and fixes the sliced boolean case. The raw-pointer overload still needs to remain accessible for callers that already supply an absolute offset.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "A-makarim (via GitHub)" <gi...@apache.org>.
A-makarim commented on PR #51240:
URL: https://github.com/apache/arrow/pull/51240#issuecomment-5609898976

   Thanks for validating this against the reproducer and for spotting the misplaced comment. Fixed in efb7d1f.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "singhpratech (via GitHub)" <gi...@apache.org>.
singhpratech commented on PR #51240:
URL: https://github.com/apache/arrow/pull/51240#issuecomment-5609627857

   Tested this against the reproducer from #51223: with the branch built locally, `fill_null_forward`,
   `fill_null_backward` and `replace_with_mask` give the same result for `full.slice(3, 5)` as for a
   fresh copy of the same values, and both new tests fail with `copy_data_internal.h` from main, so
   they cover the bug. One small thing: `FillNullSlicedArray` landed between the comment that describes
   `FillNullForwardChunkedArray` and that test, so the comment now sits above the wrong one.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-51223: [C++] Fix copying sliced boolean arrays [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #51240:
URL: https://github.com/apache/arrow/pull/51240#issuecomment-5795126650

   Rebased.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org