| 841 | } |
| 842 | |
| 843 | FieldVector Field::Flatten() const { |
| 844 | FieldVector flattened; |
| 845 | if (type_->id() == Type::STRUCT) { |
| 846 | for (const auto& child : type_->fields()) { |
| 847 | auto flattened_child = child->Copy(); |
| 848 | flattened.push_back(flattened_child); |
| 849 | flattened_child->name_.insert(0, name() + "."); |
| 850 | flattened_child->nullable_ |= nullable_; |
| 851 | } |
| 852 | } else { |
| 853 | flattened.push_back(this->Copy()); |
| 854 | } |
| 855 | return flattened; |
| 856 | } |
| 857 | |
| 858 | std::shared_ptr<Field> Field::Copy() const { |
| 859 | return ::arrow::field(name_, type_, nullable_, metadata_); |