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



##########
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:
       Cases like `const auto& obs = checked_cast<const Type&>(*some_var);` 
will actually generate a `std::bad_cast` exception so we wouldn't have to worry 
about those cases.  I suspect it could be solved with specialization.  Zulip 
dev is probably a good place for it.  No need to tackle in this PR.




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