RussellSpitzer commented on code in PR #16293:
URL: https://github.com/apache/iceberg/pull/16293#discussion_r4210506771
##########
core/src/test/java/org/apache/iceberg/TestTableMetadata.java:
##########
@@ -2186,4 +2187,60 @@ public void testSetRefRejectsTagForMainBranch() {
.build();
assertThat(withTag.ref("tag1").isTag()).isTrue();
}
+
+ @Test
+ public void addSnapshotRejectsNonMonotonicTimestampForV4() {
+ TableMetadata base =
+ TableMetadata.newTableMetadata(
+ TEST_SCHEMA,
+ PartitionSpec.unpartitioned(),
+ TEST_LOCATION,
+ ImmutableMap.of(TableProperties.FORMAT_VERSION, "4"));
+
+ Snapshot parent =
+ new BaseSnapshot(1, 1L, null, 1_000L, null, null, null,
"file:/s1.avro", 0L, 0L, null);
+ TableMetadata withParent =
TableMetadata.buildFrom(base).addSnapshot(parent).build();
+
+ Snapshot child =
+ new BaseSnapshot(2, 2L, 1L, 1_000L, null, null, null, "file:/s2.avro",
0L, 0L, null);
+
+ assertThatThrownBy(() ->
TableMetadata.buildFrom(withParent).addSnapshot(child))
+ .isInstanceOf(ValidationException.class)
+ .hasMessage("Invalid snapshot timestamp 1000: not after parent
snapshot 1 at 1000");
+ }
+
+ @Test
+ public void addSnapshotAllowsNonMonotonicTimestampBeforeV4() {
+ TableMetadata base =
+ TableMetadata.newTableMetadata(
+ TEST_SCHEMA, PartitionSpec.unpartitioned(), "location",
ImmutableMap.of());
Review Comment:
Probably need to explicitly pass through version here
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]