| 843 | } |
| 844 | |
| 845 | Status GroupToSchemaField(const GroupNode& node, LevelInfo current_levels, |
| 846 | SchemaTreeContext* ctx, const SchemaField* parent, |
| 847 | SchemaField* out) { |
| 848 | if (node.logical_type()->is_list()) { |
| 849 | return ListToSchemaField(node, current_levels, ctx, parent, out); |
| 850 | } else if (node.logical_type()->is_map()) { |
| 851 | return MapToSchemaField(node, current_levels, ctx, parent, out); |
| 852 | } |
| 853 | std::shared_ptr<ArrowType> type; |
| 854 | if (node.is_repeated()) { |
| 855 | // Simple repeated struct |
| 856 | // |
| 857 | // repeated group $NAME { |
| 858 | // r/o TYPE[0] f0 |
| 859 | // r/o TYPE[1] f1 |
| 860 | // } |
| 861 | out->children.resize(1); |
| 862 | |
| 863 | int16_t repeated_ancestor_def_level = current_levels.IncrementRepeated(); |
| 864 | RETURN_NOT_OK(GroupToStruct(node, current_levels, ctx, out, &out->children[0])); |
| 865 | ARROW_ASSIGN_OR_RAISE(auto list_type, |
| 866 | MakeArrowList(out->children[0].field, ctx->properties)); |
| 867 | out->field = ::arrow::field(node.name(), std::move(list_type), |
| 868 | /*nullable=*/false, FieldIdMetadata(node.field_id())); |
| 869 | |
| 870 | ctx->LinkParent(&out->children[0], out); |
| 871 | out->level_info = current_levels; |
| 872 | // At this point current_levels contains this list as the def level, we need to |
| 873 | // use the previous ancestor of this list. |
| 874 | out->level_info.repeated_ancestor_def_level = repeated_ancestor_def_level; |
| 875 | return Status::OK(); |
| 876 | } else { |
| 877 | current_levels.Increment(node); |
| 878 | return GroupToStruct(node, current_levels, ctx, parent, out); |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | Status NodeToSchemaField(const Node& node, LevelInfo current_levels, |
| 883 | SchemaTreeContext* ctx, const SchemaField* parent, |
no test coverage detected