You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Compute] partition_nth_indices segfaults or returns wrong result with ChunkedArray input #55775
Claude states: In vector_array_sort.cc, partition_nth_indices reuses the base kernel from array_sort_indices without resetting exec_chunked, so chunked input runs ArraySortIndicesChunked with PartitionNthOptions. Chunked input should either be supported properly or raise an error.
Found while working on the compute stubs (#49201).
I looked into the failure in pc.partition_nth_indices when evaluated on a ChunkedArray.
Findings
When executing over an arrow::Array, PartitionNthIndicesKernel accesses a single contiguous data buffer. However, when called on a ChunkedArray, the kernel fails to resolve global logical indices across chunk boundaries, resulting in either per-chunk reset indices or out-of-bounds pointer dereferences (SIGSEGV).
Proposed Solution
Avoid materializing a full contiguous copy of the ChunkedArray in memory to prevent memory doubling on large datasets.
Adapt PartitionNthIndicesKernel to follow the pattern used in SortIndices: create an indirect index array $[0, N-1]$ and supply a custom comparator that translates logical index $i$ to (chunk_idx, offset_in_chunk) via binary search or chunk offset lookup tables.
Add GoogleTest coverage in vector_sort_test.cc with multi-chunk arrays of varying/empty chunk sizes, including null placement checks (NullPlacement::AtStart / AtEnd).
Would you prefer the chunk offset lookup approach, or is there an ongoing effort to generalize PartitionNth under the broader Acero chunked compute interface?
Activity
rvcreationworld commentedon Nov 25, 2026
Hi @kou @pitrou,
I looked into the failure in
pc.partition_nth_indiceswhen evaluated on aChunkedArray.Findings
When executing over an
arrow::Array,PartitionNthIndicesKernelaccesses a single contiguous data buffer. However, when called on aChunkedArray, the kernel fails to resolve global logical indices across chunk boundaries, resulting in either per-chunk reset indices or out-of-bounds pointer dereferences (SIGSEGV).Proposed Solution
ChunkedArrayin memory to prevent memory doubling on large datasets.PartitionNthIndicesKernelto follow the pattern used inSortIndices: create an indirect index array(chunk_idx, offset_in_chunk)via binary search or chunk offset lookup tables.vector_sort_test.ccwith multi-chunk arrays of varying/empty chunk sizes, including null placement checks (NullPlacement::AtStart/AtEnd).Would you prefer the chunk offset lookup approach, or is there an ongoing effort to generalize
PartitionNthunder the broader Acero chunked compute interface?