From 0cabd93bc4b9a8b59278c3c7e0ad612413fe1b2c Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Mon, 12 Jan 2026 11:30:44 +0900 Subject: [PATCH] MINOR: [C++] Clarify null count behavior in replace_with_mask slice operation --- cpp/src/arrow/compute/kernels/vector_replace.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/vector_replace.cc b/cpp/src/arrow/compute/kernels/vector_replace.cc index 3fda3f8425d..1a3e743784d 100644 --- a/cpp/src/arrow/compute/kernels/vector_replace.cc +++ b/cpp/src/arrow/compute/kernels/vector_replace.cc @@ -252,12 +252,13 @@ struct ReplaceMaskImpl> { MakeArrayFromScalar(*replacements.scalar, array.length, ctx->memory_pool())); out->value = std::move(replacement_array->data()); } else { - // Set to be a slice of replacements + // Set to be a slice of replacements. We manually adjust offset/length instead of + // calling ArrayData::Slice() to avoid creating an extra copy. std::shared_ptr result = replacements.array.ToArrayData(); result->offset += replacements_offset; result->length = array.length; - - // TODO(wesm): why is the replacements null count not sufficient? + // The null count from the original replacements array is not sufficient because + // it applies to the entire array, not this specific slice. Must mark as unknown. result->null_count = kUnknownNullCount; out->value = result; }