public static Schema mergeWideningNullable(Schema schema1, Schema schema2) {
    if (schema1.getFieldCount() != schema2.getFieldCount()) {
      throw new IllegalArgumentException(
          "Cannot merge schemas with different numbers of fields. "
              + "schema1: "
              + schema1
              + " schema2: "
              + schema2);
    }
    Schema.Builder builder = Schema.builder();
    for (int i = 0; i < schema1.getFieldCount(); ++i) {
      String name = schema1.getField(i).getName();
      builder.addField(
          name, widenNullableTypes(schema1.getField(i).getType(), schema2.getField(i).getType()));
    }
    return builder.build();
  }
@Test
  public void testWidenMap() {
    Schema schema1 =
        Schema.builder().addMapField("field1", FieldType.INT32, FieldType.INT32).build();
    Schema schema2 =
        Schema.builder()
            .addMapField(
                "field1", FieldType.INT32.withNullable(true), FieldType.INT32.withNullable(true))
            .build();
    Schema expected =
        Schema.builder()
            .addMapField(
                "field1", FieldType.INT32.withNullable(true), FieldType.INT32.withNullable(true))
            .build();
    assertEquals(expected, SchemaUtils.mergeWideningNullable(schema1, schema2));
  }