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,
)
| 467 | /// compatibility validation) and execution time (to decide whether to route |
| 468 | /// through [`cast_column`] instead of Arrow's generic cast). |
| 469 | pub 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 | /// |
no test coverage detected
searching dependent graphs…