parquet-cli/src/main/java/org/apache/parquet/cli/util/Schemas.java
public static Schema merge(Iterable<Schema> schemas) {
    Iterator<Schema> iter = schemas.iterator();
    if (!iter.hasNext()) {
      return null;
    }
    Schema result = iter.next();
    while (iter.hasNext()) {
      result = merge(result, iter.next());
    }
    return result;
  }
public static Schema merge(Iterable<Schema> schemas) {
    Iterator<Schema> iter = schemas.iterator();
    if (!iter.hasNext()) {
      return null;
    }
    Schema result = iter.next();
    while (iter.hasNext()) {
      result = merge(result, iter.next());
    }
    return result;
  }
public static Schema merge ( Iterable < Schema > schemas ) { Iterator < Schema > iter = schemas . iterator ( ) ; if ( ! iter . hasNext ( ) ) { return null ; } Schema result = iter . next ( ) ; while ( iter . hasNext ( ) ) { result = merge ( result , iter . next ( ) ) ; } return result ; }
Merges {@link Schema} instances if they are compatible.
<p>
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, array element, and record field types types will use unions if
necessary, and union schemas are merged recursively.

@param schemas a set of {@code Schema} instances to merge
@return a merged {@code Schema}
@throws IllegalStateException if the schemas are not compatible
Merges { @link Schema } instances if they are compatible . <p > 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 array element and record field types types will use unions if necessary and union schemas are merged recursively .