| 984 | Result<bool> ApplyOriginalMetadata(const Field& origin_field, SchemaField* inferred); |
| 985 | |
| 986 | std::function<std::shared_ptr<::arrow::DataType>(FieldVector)> GetNestedFactory( |
| 987 | const ArrowType& origin_type, const ArrowType& inferred_type) { |
| 988 | switch (inferred_type.id()) { |
| 989 | case ::arrow::Type::STRUCT: |
| 990 | if (origin_type.id() == ::arrow::Type::STRUCT) { |
| 991 | return [](FieldVector fields) { return ::arrow::struct_(std::move(fields)); }; |
| 992 | } |
| 993 | break; |
| 994 | case ::arrow::Type::LIST: |
| 995 | case ::arrow::Type::LARGE_LIST: |
| 996 | if (origin_type.id() == ::arrow::Type::LIST) { |
| 997 | return [](FieldVector fields) { |
| 998 | DCHECK_EQ(fields.size(), 1); |
| 999 | return ::arrow::list(std::move(fields[0])); |
| 1000 | }; |
| 1001 | } |
| 1002 | if (origin_type.id() == ::arrow::Type::LARGE_LIST) { |
| 1003 | return [](FieldVector fields) { |
| 1004 | DCHECK_EQ(fields.size(), 1); |
| 1005 | return ::arrow::large_list(std::move(fields[0])); |
| 1006 | }; |
| 1007 | } |
| 1008 | if (origin_type.id() == ::arrow::Type::FIXED_SIZE_LIST) { |
| 1009 | const auto list_size = |
| 1010 | checked_cast<const ::arrow::FixedSizeListType&>(origin_type).list_size(); |
| 1011 | return [list_size](FieldVector fields) { |
| 1012 | DCHECK_EQ(fields.size(), 1); |
| 1013 | return ::arrow::fixed_size_list(std::move(fields[0]), list_size); |
| 1014 | }; |
| 1015 | } |
| 1016 | break; |
| 1017 | case ::arrow::Type::MAP: |
| 1018 | if (origin_type.id() == ::arrow::Type::MAP) { |
| 1019 | const bool keys_sorted = |
| 1020 | checked_cast<const ::arrow::MapType&>(origin_type).keys_sorted(); |
| 1021 | return [keys_sorted](FieldVector fields) { |
| 1022 | DCHECK_EQ(fields.size(), 1); |
| 1023 | return std::make_shared<::arrow::MapType>(std::move(fields[0]), keys_sorted); |
| 1024 | }; |
| 1025 | } |
| 1026 | break; |
| 1027 | default: |
| 1028 | break; |
| 1029 | } |
| 1030 | return {}; |
| 1031 | } |
| 1032 | |
| 1033 | Result<bool> ApplyOriginalStorageMetadata(const Field& origin_field, |
| 1034 | SchemaField* inferred) { |
no test coverage detected