yihua commented on code in PR #13556:
URL: https://github.com/apache/hudi/pull/13556#discussion_r2213712751
##########
hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/table/TestHoodieMergeOnReadTable.java:
##########
@@ -443,16 +449,51 @@ public void testLogFileCountsAfterCompaction() throws
Exception {
Dataset<Row> actual = HoodieClientTestUtils.read(
jsc(), basePath(), sqlContext(), hoodieStorage(),
fullPartitionPaths);
List<Row> rows = actual.collectAsList();
- assertEquals(updatedRecords.size(), rows.size());
+ assertEquals(90, rows.size());
+ int updatedCount = 0;
for (Row row : rows) {
- assertEquals(row.getAs(HoodieRecord.COMMIT_TIME_METADATA_FIELD),
newCommitTime);
+ if
(row.getAs(HoodieRecord.COMMIT_TIME_METADATA_FIELD).equals(newCommitTime)) {
+ updatedCount++;
+ } else {
+ // check that the commit time is 100 for all records that are not
updated
+ assertEquals(firstCommitTime,
row.getAs(HoodieRecord.COMMIT_TIME_METADATA_FIELD));
+ }
// check that file names metadata is updated
assertTrue(row.getString(HoodieRecord.FILENAME_META_FIELD_ORD).contains(compactionInstantTime));
}
+ // check that 80 records are updated
+ assertEquals(80, updatedCount);
}
}
}
+ private static void validateCompactionMetadata(HoodieCommitMetadata
compactionMetadata, String previousCommit, long expectedTotalRecordsWritten,
long expectedTotalUpdatedRecords,
+ long
expectedTotalInsertedRecords, long expectedTotalDeletedRecords) {
+ long totalRecordsWritten = 0;
+ long totalDeletedRecords = 0;
+ long totalUpdatedRecords = 0;
+ long totalInsertedRecords = 0;
+ for (HoodieWriteStat writeStat : compactionMetadata.getWriteStats()) {
+ totalRecordsWritten += writeStat.getNumWrites();
+ totalDeletedRecords += writeStat.getNumDeletes();
+ totalUpdatedRecords += writeStat.getNumUpdateWrites();
+ totalInsertedRecords += writeStat.getNumInserts();
+ assertEquals(previousCommit, writeStat.getPrevCommit());
+ assertNotNull(writeStat.getFileId());
+ assertNotNull(writeStat.getPath());
+ assertTrue(writeStat.getFileSizeInBytes() > 0);
+ assertTrue(writeStat.getTotalWriteBytes() > 0);
+ assertTrue(writeStat.getTotalLogBlocks() > 0);
+ assertTrue(writeStat.getTotalLogSizeCompacted() > 0);
+ assertTrue(writeStat.getTotalLogFilesCompacted() > 0);
+ assertTrue(writeStat.getTotalLogRecords() > 0);
+ }
+ assertEquals(expectedTotalRecordsWritten, totalRecordsWritten);
+ assertEquals(expectedTotalUpdatedRecords, totalUpdatedRecords);
+ assertEquals(expectedTotalInsertedRecords, totalInsertedRecords);
Review Comment:
Should we curate a test case where the `totalInsertedRecords` is non-zero?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]