tustvold commented on code in PR #4400:
URL: https://github.com/apache/arrow-rs/pull/4400#discussion_r1226400520


##########
arrow-array/src/builder/struct_builder.rs:
##########
@@ -240,42 +240,24 @@ impl StructBuilder {
     pub fn finish(&mut self) -> StructArray {
         self.validate_content();
 
-        let mut child_data = Vec::with_capacity(self.field_builders.len());
-        for f in &mut self.field_builders {
-            let arr = f.finish();
-            child_data.push(arr.to_data());
-        }
-        let length = self.len();
+        let arrays = self.field_builders.iter_mut().map(|f| 
f.finish()).collect();
         let nulls = self.null_buffer_builder.finish();
-
-        let builder = ArrayData::builder(DataType::Struct(self.fields.clone()))
-            .len(length)
-            .child_data(child_data)
-            .nulls(nulls);
-
-        let array_data = unsafe { builder.build_unchecked() };
-        StructArray::from(array_data)
+        StructArray::new(self.fields.clone(), arrays, nulls)

Review Comment:
   As ArrayBuilder doesn't expose a data_type we can't validate the builders 
eagerly, but we can at least verify on finish



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