parquet-cli/src/main/java/org/apache/parquet/cli/util/Schemas.java
public static Schema merge(Schema left, Schema right) {
    Schema merged = mergeOnly(left, right);
    Preconditions.checkState(merged != null,
        "Cannot merge %s and %s", left, right);
    return merged;
  }
public static Schema merge(Schema left, Schema right) {
    Schema merged = mergeOnly(left, right);
    Preconditions.checkState(merged != null,
        "Cannot merge %s and %s", left, right);
    return merged;
  }
Merges two {@link Schema} instances if they are compatible.
<p>
Two schemas are incompatible if:
<ul>
<li>The {@link Schema.Type} does not match.</li>
<li>For record schemas, the record name does not match</li>
<li>For enum schemas, the enum name does not match</li>
</ul>
<p>
Map value and array element types will use unions if necessary, and union
schemas are merged recursively.

@param left a {@code Schema}
@param right a {@code Schema}
@return a merged {@code Schema}
@throws IllegalStateException if the schemas are not compatible