You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/11/16 00:52:50 UTC

[GitHub] [iceberg] zhengzengprc commented on a change in pull request #3039: Introduce spark3 option to read stream from a timestamp

zhengzengprc commented on a change in pull request #3039:
URL: https://github.com/apache/iceberg/pull/3039#discussion_r749815932



##########
File path: core/src/main/java/org/apache/iceberg/util/SnapshotUtil.java
##########
@@ -65,12 +65,18 @@ public static boolean ancestorOf(Table table, long snapshotId, long ancestorSnap
   }
 
   /**
-   * Traverses the history of the table's current snapshot and finds the oldest Snapshot.
-   * @return null if there is no current snapshot in the table, else the oldest Snapshot.
+   * Traverses the history of the table's current snapshot
+   * and finds the oldest Snapshot after or equal to the timestamp in milliseconds.
+   * @return null if there is no current snapshot in the table,
+   * else the oldest Snapshot after or equal to the timestamp in milliseconds.
    */
-  public static Snapshot oldestSnapshot(Table table) {
+  public static Snapshot oldestSnapshot(Table table, long timestampMillis) {

Review comment:
       Thanks @rdblue, it is a very interesting problem to handle the expired snapshot. I can reproduce the problem in unit test. I am thinking about it is better way to loop the snapshots without the parentId
   `  public static Snapshot snapshotAfter(Table table, long snapshotId) {
       Preconditions.checkArgument(table.snapshot(snapshotId) != null, "Cannot find parent snapshot: %s", snapshotId);
   
       Snapshot current = table.currentSnapshot();
       while (current != null) {
         if (current.parentId() == snapshotId) {
           return current;
         }
   
         current = table.snapshot(current.parentId());
       }
   
       throw new IllegalStateException(
           String.format("Cannot find snapshot after %s: not an ancestor of table's current snapshot", snapshotId));
     }`
   It seems like we have similar issue with the above code block when some of the previous snapshot expired




-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org