Jefffrey commented on code in PR #5585:
URL: https://github.com/apache/arrow-rs/pull/5585#discussion_r1551301091
##########
arrow-array/src/array/union_array.rs:
##########
@@ -319,6 +319,39 @@ impl UnionArray {
fields,
}
}
+
+ /// Deconstruct this array into its constituent parts
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # use arrow_array::types::Int32Type;
+ /// # use arrow_array::builder::UnionBuilder;
+ /// # fn main() -> Result<(), arrow_schema::ArrowError> {
+ /// let mut builder = UnionBuilder::new_dense();
+ /// builder.append::<Int32Type>("a", 1).unwrap();
+ /// let union_array = builder.build()?;
+ /// let (data_type, type_ids, offsets, fields) = union_array.into_parts();
+ /// # Ok(())
+ /// # }
+ /// ```
+ #[allow(clippy::type_complexity)]
+ pub fn into_parts(
+ self,
+ ) -> (
+ DataType,
+ ScalarBuffer<i8>,
+ Option<ScalarBuffer<i32>>,
+ Vec<Option<ArrayRef>>,
+ ) {
+ let Self {
+ data_type,
+ type_ids,
+ offsets,
+ fields,
+ } = self;
+ (data_type, type_ids, offsets, fields)
+ }
Review Comment:
It seems PrimitiveArray is the only other array type that returns a
`DataType` as part of its `into_parts()`
Maybe just return the fields, akin to how StructArray does it? (Though
unsure about the Sparse/Dense enum)
--
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]