MCPcopy Create free account
hub / github.com/apache/datafusion / requires_nested_struct_cast

Function requires_nested_struct_cast

datafusion/common/src/nested_struct.rs:469–486  ·  view source on GitHub ↗

Returns true if casting from `source_type` to `target_type` requires name-based nested struct casting logic, rather than Arrow's standard cast. This is the case when both types are struct types, or both are the same container type (List, LargeList, ListView, LargeListView, Dictionary) wrapping types that recursively contain structs. Use this predicate at both planning time (to decide whether to

(
    source_type: &DataType,
    target_type: &DataType,
)

Source from the content-addressed store, hash-verified

467/// compatibility validation) and execution time (to decide whether to route
468/// through [`cast_column`] instead of Arrow's generic cast).
469pub fn requires_nested_struct_cast(
470 source_type: &DataType,
471 target_type: &DataType,
472) -> bool {
473 match (source_type, target_type) {
474 (Struct(_), Struct(_)) => true,
475 (DataType::List(s), DataType::List(t))
476 | (DataType::LargeList(s), DataType::LargeList(t))
477 | (DataType::ListView(s), DataType::ListView(t))
478 | (DataType::LargeListView(s), DataType::LargeListView(t)) => {
479 requires_nested_struct_cast(s.data_type(), t.data_type())
480 }
481 (DataType::Dictionary(_, s_val), DataType::Dictionary(_, t_val)) => {
482 requires_nested_struct_cast(s_val, t_val)
483 }
484 _ => false,
485 }
486}
487
488/// Check if two field lists have at least one common field by name.
489///

Callers 3

cast_with_target_fieldFunction · 0.85
cast_array_by_nameFunction · 0.85
cast_to_with_optionsMethod · 0.85

Calls 1

data_typeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…