Skip to content

Conversation

@friendlymatthew
Copy link
Contributor

Which issue does this PR close?

This PR adds another method on the UnionArray api that returns a list of FieldRefs associated with the union type

See: #8838 (comment)

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 19, 2025
Copy link
Contributor Author

@friendlymatthew friendlymatthew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self review

Comment on lines 314 to 328
/// Returns the list of [`FieldRef`]s in 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() {
DataType::Union(_, mode) => mode == &UnionMode::Dense,
_ => unreachable!("Union array's data type is not a union!"),
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out we can derive the UnionMode by calling UnionArray::is_dense. But I wonder if a better API would to actually return the enum 🤔

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alamb alamb merged commit 5f3577a into apache:main Nov 24, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants