Skip to content

[C++][Compute] Implement casting from ListView/LargeListView to List/LargeList #50994

Description

@Jay846

Describe the enhancement requested

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.

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions