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