nastra commented on code in PR #12593: URL: https://github.com/apache/iceberg/pull/12593#discussion_r2012472001
########## core/src/test/java/org/apache/iceberg/TestRowLineageMetadata.java: ########## @@ -70,20 +70,44 @@ public void cleanup() { TestTables.clearTables(); } - @TestTemplate - public void testRowLineageSupported() { - if (formatVersion >= TableMetadata.MIN_FORMAT_VERSION_ROW_LINEAGE) { - assertThat(TableMetadata.buildFromEmpty(formatVersion).enableRowLineage()).isNotNull(); - } else { - assertThatThrownBy(() -> TableMetadata.buildFromEmpty(formatVersion).enableRowLineage()) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("Cannot use row lineage"); - } + @Test + public void testSnapshotRowIDValidation() { + Snapshot snapshot = + new BaseSnapshot(0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", null, null); + assertThat(snapshot.firstRowId()).isNull(); + assertThat(snapshot.addedRows()).isNull(); + + // added-rows will be set to null if first-row-id is null + snapshot = + new BaseSnapshot(0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", null, 10L); + assertThat(snapshot.firstRowId()).isNull(); + assertThat(snapshot.addedRows()).isNull(); + + // added-rows and first-row-id can be 0 + snapshot = new BaseSnapshot(0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 0L, 0L); + assertThat(snapshot.firstRowId()).isEqualTo(0); + assertThat(snapshot.addedRows()).isEqualTo(0); + + assertThatThrownBy( + () -> + new BaseSnapshot( + 0, 1, null, 0, DataOperations.APPEND, null, 1, "ml.avro", 10L, null)) + .hasMessage("Invalid added-rows (required when first-row-id is set): null"); Review Comment: we typically try to also check for the underlying exception via `.isInstanceOf(...)` here and in the few lines below -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org