mapleFU commented on code in PR #43782:
URL: https://github.com/apache/arrow/pull/43782#discussion_r1945885089


##########
cpp/src/arrow/compute/kernels/scalar_cast_nested.cc:
##########
@@ -404,14 +400,20 @@ struct CastStruct {
 
     int out_field_index = 0;
     for (int field_index : fields_to_select) {
-      const auto& target_type = out->type()->field(out_field_index++)->type();
+      const auto& target_field = out->type()->field(out_field_index++);
+      const auto& target_type = target_field->type();
       if (field_index == kFillNullSentinel) {
         ARROW_ASSIGN_OR_RAISE(auto nulls,
                               MakeArrayOfNull(target_type->GetSharedPtr(), 
batch.length));
         out_array->child_data.push_back(nulls->data());
       } else {
         const auto& values = 
(in_array.child_data[field_index].ToArrayData()->Slice(
             in_array.offset, in_array.length));
+        if (!target_field->nullable() && values->null_count > 0) {
+          return Status::TypeError("field '", target_field->name(),

Review Comment:
   Ignore me, i previously think we can
   
   ```
           auto values = (in_array.child_data[field_index].ToArrayData()->Slice(
               in_array.offset, in_array.length));
          if (out field not nullable but in field nullable) {
             if (values->GetNullCount() > 0) {
                return error
             }
             values->buffers[0].reset();
          }
   ```
   
   But I also think this doesn't matter here



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