public static Optional<TableSchema> getUpdatedSchema(
      TableSchema oldSchema, TableSchema newSchema) {
    Result updatedFields = getUpdatedSchema(oldSchema.getFieldsList(), newSchema.getFieldsList());
    if (updatedFields.isEquivalent()) {
      return Optional.empty();
    } else {
      return updatedFields
          .getFields()
          .map(
              tableFieldSchemas ->
                  TableSchema.newBuilder().addAllFields(tableFieldSchemas).build());
    }
  }
@Test
  public void testEquivalentSchema() {
    TableSchema baseSchema1 =
        TableSchema.newBuilder()
            .addFields(
                TableFieldSchema.newBuilder().setName("a").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("b").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("c").setType(TableFieldSchema.Type.STRING))
            .build();
    TableSchema schema1 =
        TableSchema.newBuilder()
            .addFields(
                TableFieldSchema.newBuilder().setName("a").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("b").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("c").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder()
                    .setName("nested")
                    .setType(TableFieldSchema.Type.STRUCT)
                    .addAllFields(baseSchema1.getFieldsList()))
            .build();

    TableSchema baseSchema2 =
        TableSchema.newBuilder()
            .addFields(
                TableFieldSchema.newBuilder().setName("c").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("b").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("a").setType(TableFieldSchema.Type.STRING))
            .build();
    TableSchema schema2 =
        TableSchema.newBuilder()
            .addFields(
                TableFieldSchema.newBuilder()
                    .setName("nested")
                    .setType(TableFieldSchema.Type.STRUCT)
                    .addAllFields(baseSchema2.getFieldsList()))
            .addFields(
                TableFieldSchema.newBuilder().setName("b").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("c").setType(TableFieldSchema.Type.STRING))
            .addFields(
                TableFieldSchema.newBuilder().setName("a").setType(TableFieldSchema.Type.STRING))
            .build();
    assertFalse(TableSchemaUpdateUtils.getUpdatedSchema(schema1, schema2).isPresent());
  }