| 2688 | } |
| 2689 | |
| 2690 | Result<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 |