diff --git a/cpp/velox/shuffle/VeloxHashShuffleWriter.cc b/cpp/velox/shuffle/VeloxHashShuffleWriter.cc index f57a0a624dc5..6024f04ab19b 100644 --- a/cpp/velox/shuffle/VeloxHashShuffleWriter.cc +++ b/cpp/velox/shuffle/VeloxHashShuffleWriter.cc @@ -111,7 +111,7 @@ arrow::Status collectFlatVectorBufferStringView( auto* rawLength = reinterpret_cast(lengthBuffer->mutable_data()); uint64_t offset = 0; for (int32_t i = 0; i < flatVector->size(); i++) { - auto length = rawValues[i].size(); + auto length = flatVector->isNullAt(i) ? 0 : rawValues[i].size(); *rawLength++ = length; offset += length; } @@ -120,6 +120,9 @@ arrow::Status collectFlatVectorBufferStringView( ARROW_ASSIGN_OR_RAISE(auto valueBuffer, arrow::AllocateResizableBuffer(offset, pool)); auto raw = reinterpret_cast(valueBuffer->mutable_data()); for (int32_t i = 0; i < flatVector->size(); i++) { + if (flatVector->isNullAt(i)) { + continue; + } gluten::fastCopy(raw, rawValues[i].data(), rawValues[i].size()); raw += rawValues[i].size(); }