This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 5f3577a889 Add UnionArray::fields (#8884)
5f3577a889 is described below
commit 5f3577a889f8a80fdc1551457cf968a02f0e5e05
Author: Matthew Kim <[email protected]>
AuthorDate: Mon Nov 24 16:11:45 2025 -0500
Add UnionArray::fields (#8884)
# Which issue does this PR close?
This PR adds another method on the `UnionArray` api that returns a list
of `FieldRef`s associated with the union type
See: https://github.com/apache/arrow-rs/pull/8838#discussion_r2543160023
---
arrow-array/src/array/union_array.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arrow-array/src/array/union_array.rs
b/arrow-array/src/array/union_array.rs
index 478ca0013e..a133998bb2 100644
--- a/arrow-array/src/array/union_array.rs
+++ b/arrow-array/src/array/union_array.rs
@@ -311,6 +311,14 @@ impl UnionArray {
}
}
+ /// Returns the [`UnionFields`] for the union.
+ pub fn fields(&self) -> &UnionFields {
+ match self.data_type() {
+ DataType::Union(fields, _) => fields,
+ _ => unreachable!("Union array's data type is not a union!"),
+ }
+ }
+
/// Returns whether the `UnionArray` is dense (or sparse if `false`).
pub fn is_dense(&self) -> bool {
match self.data_type() {