public static void validateData(Table table, List<Record> expected, int sortBy) throws IOException {
    // Refresh the table, so we get the new data as well
    table.refresh();
    List<Record> records = Lists.newArrayListWithExpectedSize(expected.size());
    try (CloseableIterable<Record> iterable = IcebergGenerics.read(table).build()) {
      iterable.forEach(records::add);
    }

    validateData(expected, records, sortBy);
  }
Validates whether the table contains the expected records. The results should be sorted by a unique key so we do
not end up with flaky tests.
@param table The table we should read the records from
@param expected The expected list of Records
@param sortBy The column position by which we will sort
@throws IOException Exceptions when reading the table data
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java