nevi-me commented on a change in pull request #7365:
URL: https://github.com/apache/arrow/pull/7365#discussion_r436257140



##########
File path: rust/arrow/src/array/builder.rs
##########
@@ -1018,6 +1271,50 @@ impl ArrayBuilder for StructBuilder {
         self.len
     }
 
+    /// Appends data from other arrays into the builder
+    ///
+    /// This is most useful when concatenating arrays of the same type into a 
builder.
+    fn append_data(&mut self, data: &[ArrayDataRef]) -> Result<()> {
+        for array in data {
+            if let DataType::Struct(fields) = array.data_type() {
+                if &self.fields != fields {
+                    return Err(ArrowError::InvalidArgumentError(
+                        "Struct arrays are not the same".to_string(),
+                    ));
+                }
+                let len = array.len();
+                if len == 0 {
+                    continue;
+                }
+                let offset = array.offset();
+                let results: Result<Vec<()>> = self
+                    .field_builders
+                    .iter_mut()
+                    .zip(array.child_data())
+                    .map(|(builder, child_data)| {
+                        // slice child_data to account for offsets
+                        let child_array = make_array(child_data.clone());
+                        let sliced = child_array.slice(offset, len);
+                        builder.append_data(&[sliced.data()])
+                    })
+                    .collect();
+                results?;

Review comment:
       Thanks, I've changed it




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to