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

Function UnifySchemas

cpp/src/arrow/type.cc:2690–2712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2688}
2689
2690Result<std::shared_ptr<Schema>> UnifySchemas(
2691 const std::vector<std::shared_ptr<Schema>>& schemas,
2692 const Field::MergeOptions field_merge_options) {
2693 if (schemas.empty()) {
2694 return Status::Invalid("Must provide at least one schema to unify.");
2695 }
2696
2697 if (!schemas[0]->HasDistinctFieldNames()) {
2698 return Status::Invalid("Can't unify schema with duplicate field names.");
2699 }
2700
2701 SchemaBuilder builder{schemas[0], SchemaBuilder::CONFLICT_MERGE, field_merge_options};
2702
2703 for (size_t i = 1; i < schemas.size(); i++) {
2704 const auto& schema = schemas[i];
2705 if (!schema->HasDistinctFieldNames()) {
2706 return Status::Invalid("Can't unify schema with duplicate field names.");
2707 }
2708 RETURN_NOT_OK(builder.AddSchema(schema));
2709 }
2710
2711 return builder.Finish();
2712}
2713
2714// ----------------------------------------------------------------------
2715// Fingerprint computations

Callers 4

ConcatenateTablesFunction · 0.85
TEST_FFunction · 0.85
InspectMethod · 0.85
arrow__UnifySchemasFunction · 0.85

Calls 6

HasDistinctFieldNamesMethod · 0.80
AddSchemaMethod · 0.80
InvalidFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
FinishMethod · 0.45

Tested by 1

TEST_FFunction · 0.68