HyukjinKwon opened a new pull request, #48803: URL: https://github.com/apache/arrow/pull/48803
### Rationale for this change The TODO comment saying explicitly setting `output->buffers[2] = nullptr` in the else branch was redundant. The output `ArrayData` is allocated by `PrepareOutput()` before the kernel executes: https://github.com/apache/arrow/blob/7be5a89ef083f38317fd94330127be5b5df648d8/cpp/src/arrow/compute/exec.cc#L907-L908 `PrepareOutput()` resizes the buffers vector to the required size for the output type (3 for String/Binary: validity, offsets, data): https://github.com/apache/arrow/blob/7be5a89ef083f38317fd94330127be5b5df648d8/cpp/src/arrow/compute/exec.cc#L729-L731 For String/Binary output types, `ComputeDataPreallocate()` only preallocates the offsets buffer (not the data buffer): https://github.com/apache/arrow/blob/7be5a89ef083f38317fd94330127be5b5df648d8/cpp/src/arrow/compute/exec.cc#L294-L298 `PrepareOutput()` only allocates buffers that are in the `data_preallocated_` vector. For String/Binary, this means only `buffers[1]` (offsets) is allocated: https://github.com/apache/arrow/blob/7be5a89ef083f38317fd94330127be5b5df648d8/cpp/src/arrow/compute/exec.cc#L739-L747 Since `std::vector::resize()`constructs all elements, `buffers[2]` is already `nullptr` from the resize call. Therefore, explicitly assigning `nullptr` in the else branch is redundant. ### What changes are included in this PR? Converted the redundant else clause to `DCHECK_EQ`. ### Are these changes tested? Yes, I locally ran`Cast.FixedSizeBinaryToBinaryOrString` and `Cast.FixedSizeBinaryToBinaryOrStringWithSlice`. ### Are there any user-facing changes? No. -- 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]
