mbrobbel commented on code in PR #5585:
URL: https://github.com/apache/arrow-rs/pull/5585#discussion_r1551310082
##########
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:
Good suggestion. In that case I think we should also return `UnionMode`
(instead of users having to check if the offsets buffer for `Some` or `None` to
figure that out):
```rust
(UnionFields, UnionMode, ScalarBuffer<i8>, Option<ScalarBuffer<i32>>,
Vec<Option<ArrayRef>>)
```
--
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]