nastra commented on code in PR #11171:
URL: https://github.com/apache/iceberg/pull/11171#discussion_r1768245203


##########
spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRollbackToTimestampProcedure.java:
##########
@@ -252,6 +254,41 @@ public void 
testRollbackToTimestampWithoutExplicitCatalog() {
         sql("SELECT * FROM %s ORDER BY id", tableName));
   }
 
+  @Test
+  public void testRollbackToTimestampBeforeOrEqualToOldestSnapshot() {
+    sql("CREATE TABLE %s (id bigint NOT NULL, data string) USING iceberg", 
tableName);
+    sql("INSERT INTO TABLE %s VALUES (1, 'a')", tableName);
+
+    Table table = validationCatalog.loadTable(tableIdent);
+    Snapshot firstSnapshot = table.currentSnapshot();
+    Timestamp beforeFirstSnapshotTimestamp =
+        Timestamp.from(Instant.ofEpochMilli(firstSnapshot.timestampMillis() - 
1));
+    Timestamp exactFirstSnapshotTimestamp =

Review Comment:
   ```suggestion
       Timestamp exactFirstSnapshot =
   ```



##########
spark/v3.3/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRollbackToTimestampProcedure.java:
##########
@@ -252,6 +254,41 @@ public void 
testRollbackToTimestampWithoutExplicitCatalog() {
         sql("SELECT * FROM %s ORDER BY id", tableName));
   }
 
+  @Test
+  public void testRollbackToTimestampBeforeOrEqualToOldestSnapshot() {
+    sql("CREATE TABLE %s (id bigint NOT NULL, data string) USING iceberg", 
tableName);
+    sql("INSERT INTO TABLE %s VALUES (1, 'a')", tableName);
+
+    Table table = validationCatalog.loadTable(tableIdent);
+    Snapshot firstSnapshot = table.currentSnapshot();
+    Timestamp beforeFirstSnapshotTimestamp =
+        Timestamp.from(Instant.ofEpochMilli(firstSnapshot.timestampMillis() - 
1));
+    Timestamp exactFirstSnapshotTimestamp =
+        Timestamp.from(Instant.ofEpochMilli(firstSnapshot.timestampMillis()));
+
+    waitUntilAfter(firstSnapshot.timestampMillis());
+    sql("INSERT INTO TABLE %s VALUES (2, 'b')", tableName);
+
+    assertThatThrownBy(
+            () ->
+                sql(
+                    "CALL %s.system.rollback_to_timestamp(timestamp => 
TIMESTAMP '%s', table => '%s')",
+                    catalogName, beforeFirstSnapshotTimestamp, tableIdent))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            "Cannot roll back, no valid snapshot older than: "

Review Comment:
   ```suggestion
               "Cannot roll back, no valid snapshot older than: %s", 
beforeFirstSnapshot.toInstant().toEpochMilli()
   ```
   
   no need to use + as you can just use %s to pass the timestamp value



-- 
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

Reply via email to