lidavidm commented on a change in pull request #11023:
URL: https://github.com/apache/arrow/pull/11023#discussion_r739522959



##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -402,16 +401,16 @@ struct StringTransformExecBase {
     if (!input.is_valid) {
       return Status::OK();
     }
-    auto* result = checked_cast<BaseBinaryScalar*>(out->scalar().get());
-    result->is_valid = true;
     const int64_t data_nbytes = static_cast<int64_t>(input.value->size());
-
     const int64_t output_ncodeunits_max = transform->MaxCodeunits(1, 
data_nbytes);
     if (output_ncodeunits_max > std::numeric_limits<offset_type>::max()) {
       return Status::CapacityError(
           "Result might not fit in a 32bit utf8 array, convert to large_utf8");
     }
+
     ARROW_ASSIGN_OR_RAISE(auto value_buffer, 
ctx->Allocate(output_ncodeunits_max));
+    auto* result = checked_cast<BaseBinaryScalar*>(out->scalar().get());

Review comment:
       We could just include the check in checked_cast?




-- 
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]


Reply via email to