MCPcopy Create free account
hub / github.com/apache/arrow / MergeStructs

Function MergeStructs

cpp/src/arrow/type.cc:687–702  ·  view source on GitHub ↗

Merge list types based on options. Returns nullptr for non-list types.

Source from the content-addressed store, hash-verified

685
686// Merge list types based on options. Returns nullptr for non-list types.
687Result<std::shared_ptr<DataType>> MergeStructs(
688 const std::shared_ptr<DataType>& promoted_type,
689 const std::shared_ptr<DataType>& other_type, const Field::MergeOptions& options) {
690 SchemaBuilder builder(SchemaBuilder::CONFLICT_APPEND, options);
691 // Add the LHS fields. Duplicates will be preserved.
692 RETURN_NOT_OK(builder.AddFields(promoted_type->fields()));
693
694 // Add the RHS fields. Duplicates will be merged, unless the field was
695 // already a duplicate, in which case we error (since we don't know which
696 // field to merge with).
697 builder.SetPolicy(SchemaBuilder::CONFLICT_MERGE);
698 RETURN_NOT_OK(builder.AddFields(other_type->fields()));
699
700 ARROW_ASSIGN_OR_RAISE(auto schema, builder.Finish());
701 return struct_(schema->fields());
702}
703
704// Merge list types based on options. Returns nullptr for non-list types.
705Result<std::shared_ptr<DataType>> MaybeMergeListTypes(

Callers 1

MaybeMergeListTypesFunction · 0.85

Calls 4

struct_Function · 0.85
AddFieldsMethod · 0.80
SetPolicyMethod · 0.80
fieldsMethod · 0.45

Tested by

no test coverage detected