This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 705d3414eb Remove `SchemaBuilder` dependency from `StructArray` 
constructors (#6139)
705d3414eb is described below

commit 705d3414eb991c234aaced332c11973e997d360f
Author: Alexander Rafferty <[email protected]>
AuthorDate: Sat Jul 27 20:41:34 2024 +1000

    Remove `SchemaBuilder` dependency from `StructArray` constructors (#6139)
---
 arrow-array/src/array/struct_array.rs | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arrow-array/src/array/struct_array.rs 
b/arrow-array/src/array/struct_array.rs
index 44a7f38c32..059bc0b5e6 100644
--- a/arrow-array/src/array/struct_array.rs
+++ b/arrow-array/src/array/struct_array.rs
@@ -18,7 +18,7 @@
 use crate::{make_array, new_null_array, Array, ArrayRef, RecordBatch};
 use arrow_buffer::{BooleanBuffer, Buffer, NullBuffer};
 use arrow_data::{ArrayData, ArrayDataBuilder};
-use arrow_schema::{ArrowError, DataType, Field, FieldRef, Fields, 
SchemaBuilder};
+use arrow_schema::{ArrowError, DataType, Field, FieldRef, Fields};
 use std::sync::Arc;
 use std::{any::Any, ops::Index};
 
@@ -326,7 +326,7 @@ impl TryFrom<Vec<(&str, ArrayRef)>> for StructArray {
 
     /// builds a StructArray from a vector of names and arrays.
     fn try_from(values: Vec<(&str, ArrayRef)>) -> Result<Self, ArrowError> {
-        let (schema, arrays): (SchemaBuilder, _) = values
+        let (fields, arrays): (Vec<_>, _) = values
             .into_iter()
             .map(|(name, array)| {
                 (
@@ -336,7 +336,7 @@ impl TryFrom<Vec<(&str, ArrayRef)>> for StructArray {
             })
             .unzip();
 
-        StructArray::try_new(schema.finish().fields, arrays, None)
+        StructArray::try_new(fields.into(), arrays, None)
     }
 }
 
@@ -397,8 +397,8 @@ impl Array for StructArray {
 
 impl From<Vec<(FieldRef, ArrayRef)>> for StructArray {
     fn from(v: Vec<(FieldRef, ArrayRef)>) -> Self {
-        let (schema, arrays): (SchemaBuilder, _) = v.into_iter().unzip();
-        StructArray::new(schema.finish().fields, arrays, None)
+        let (fields, arrays): (Vec<_>, _) = v.into_iter().unzip();
+        StructArray::new(fields.into(), arrays, None)
     }
 }
 
@@ -424,9 +424,9 @@ impl std::fmt::Debug for StructArray {
 impl From<(Vec<(FieldRef, ArrayRef)>, Buffer)> for StructArray {
     fn from(pair: (Vec<(FieldRef, ArrayRef)>, Buffer)) -> Self {
         let len = pair.0.first().map(|x| x.1.len()).unwrap_or_default();
-        let (fields, arrays): (SchemaBuilder, Vec<_>) = 
pair.0.into_iter().unzip();
+        let (fields, arrays): (Vec<_>, Vec<_>) = pair.0.into_iter().unzip();
         let nulls = NullBuffer::new(BooleanBuffer::new(pair.1, 0, len));
-        Self::new(fields.finish().fields, arrays, Some(nulls))
+        Self::new(fields.into(), arrays, Some(nulls))
     }
 }
 

Reply via email to