Skip to content

Commit 1f2aad7

Browse files
use is_nested
1 parent b47a20a commit 1f2aad7

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

arrow-cast/src/cast/union.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ fn same_type_family(a: &DataType, b: &DataType) -> bool {
4545
)
4646
}
4747

48-
fn is_complex_container(dt: &DataType) -> bool {
49-
use DataType::*;
50-
matches!(
51-
dt,
52-
List(_)
53-
| LargeList(_)
54-
| ListView(_)
55-
| LargeListView(_)
56-
| FixedSizeList(_, _)
57-
| Struct(_)
58-
| Map(_, _)
59-
)
60-
}
61-
6248
// variant selection heuristic — 3 passes with decreasing specificity:
6349
//
6450
// first pass: field type == target type
@@ -82,10 +68,10 @@ pub(crate) fn resolve_variant<'a>(
8268
.find(|(_, f)| same_type_family(f.data_type(), target_type))
8369
})
8470
.or_else(|| {
85-
// skip complex container types in pass 3 — union extraction introduces nulls,
86-
// and casting nullable arrays to containers like List/Struct/Map can fail when
87-
// inner fields are non-nullable.
88-
if is_complex_container(target_type) {
71+
// skip nested types in pass 3 — union extraction introduces nulls,
72+
// and casting nullable arrays to nested types like List/Struct/Map can fail
73+
// when inner fields are non-nullable.
74+
if target_type.is_nested() {
8975
return None;
9076
}
9177
fields

0 commit comments

Comments
 (0)