Jay846 commented on code in PR #50976:
URL: https://github.com/apache/arrow/pull/50976#discussion_r3861107207
##########
cpp/src/arrow/compute/kernels/scalar_cast_test.cc:
##########
@@ -3646,6 +3646,72 @@ TEST(Cast, ListToListOptionsPassthru) {
}
}
+TEST(Cast, ListViewToList) {
Review Comment:
Currently, Apache Arrow C++ does not support casting from ListView or
LargeListView arrays to standard List or LargeList arrays correctly.
Although the casting kernels are registered, they incorrectly route to the
standard List-to-List casting kernel (`CastList`). Because `CastList` ignores
the sizes buffer of `ListView` (assuming contiguous elements where size is
`offset[i+1] - offset[i]`) and attempts to read `length + 1` offsets from a
buffer that may only contain `length` elements, casting a `ListView` to `List`
silently produces a corrupted `ListArray` with invalid/negative offsets and
triggers out-of-bounds reads.
This enhancement introduces a dedicated casting path for
ListView/LargeListView:
1. A fast-path for contiguous ListView inputs, performing zero-copy casting
by slicing the child values array and adjusting offsets.
2. A fallback path for non-contiguous, gapped, or overlapping ListView
inputs, using indices generation and the `take` kernel to reconstruct
contiguous child values arrays before casting.
Both done!
--
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]