JonSnow1807 opened a new pull request, #54940: URL: https://github.com/apache/arrow/pull/54940
### Rationale for this change `DenseUnionArray::Make` used `type_ids.offset()` as the union offset for both the type ids and the value offsets buffers, and never checked the length of `value_offsets`. With a `value_offsets` array that is sliced differently from `type_ids` the union reads value offsets from the wrong positions (and `ValidateFull` cannot tell), and a too-short `value_offsets` array is accepted. See GH-54937; same root cause as GH-54907 (#54938). ### What changes are included in this PR? - `DenseUnionArray::Make` returns `Invalid` when `value_offsets` is shorter than `type_ids`. A longer `value_offsets` array is still tolerated (only the first `len(type_ids)` offsets are used), since existing callers rely on that. - When `type_ids` or `value_offsets` is sliced, its buffer is sliced (zero-copy) to the logical window and the union is built with offset 0. Unsliced inputs keep using the original buffers. - Regression test `TestUnionArrayFactories.TestMakeDenseSliced`. ### Are these changes tested? Yes. The new test fails on main (sliced `value_offsets` yields `[10, 20]` instead of `[20, 30]`, and the short `value_offsets` array is accepted) and passes with the fix. `arrow-array-test`, `arrow-ipc-read-write-test`, `arrow-scalar-test` and `arrow-compute-scalar-type-test` pass locally (Debug, ASan/UBSan). ### Are there any user-facing changes? `DenseUnionArray::Make` now returns `Invalid` when `value_offsets` is shorter than `type_ids`, and the resulting array has offset 0 instead of `type_ids.offset()`. AI usage disclosure: Claude Code assisted with investigating the root cause, preparing the implementation, and developing the regression test. I reviewed the changes and am responsible for their correctness. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
