Skip to content

Commit

Permalink
Add DataType::is_nested() (#2707)
Browse files Browse the repository at this point in the history
* Add DataType::is_nested()

* Fix documentation for is_nested

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>

Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
  • Loading branch information
kfastov and viirya committed Sep 12, 2022
1 parent be33fb3 commit 0ba5c5b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arrow/src/datatypes/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,20 @@ impl DataType {
)
}

/// Returns true if this type is nested (List, FixedSizeList, LargeList, Struct, Union, or Map)
pub fn is_nested(t: &DataType) -> bool {
use DataType::*;
matches!(
t,
List(_)
| FixedSizeList(_, _)
| LargeList(_)
| Struct(_)
| Union(_, _, _)
| Map(_, _)
)
}

/// Compares the datatype with another, ignoring nested field names
/// and metadata.
pub fn equals_datatype(&self, other: &DataType) -> bool {
Expand Down

0 comments on commit 0ba5c5b

Please sign in to comment.