Skip to content

Commit 5f3577a

Browse files
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: #8838 (comment)
1 parent 558f744 commit 5f3577a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arrow-array/src/array/union_array.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ impl UnionArray {
311311
}
312312
}
313313

314+
/// Returns the [`UnionFields`] for the union.
315+
pub fn fields(&self) -> &UnionFields {
316+
match self.data_type() {
317+
DataType::Union(fields, _) => fields,
318+
_ => unreachable!("Union array's data type is not a union!"),
319+
}
320+
}
321+
314322
/// Returns whether the `UnionArray` is dense (or sparse if `false`).
315323
pub fn is_dense(&self) -> bool {
316324
match self.data_type() {

0 commit comments

Comments
 (0)