jiwen624 commented on code in PR #19099:
URL: https://github.com/apache/iceberg/pull/19099#discussion_r4712176160


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/enumerator/ContinuousSplitPlannerImpl.java:
##########
@@ -220,13 +221,23 @@ private ContinuousEnumerationResult 
discoverInitialSplits() {
    */
   @VisibleForTesting
   static Optional<Snapshot> startSnapshot(Table table, ScanContext 
scanContext) {
+    String branch = scanContext.branch();
+    if (branch != null
+        && !SnapshotRef.MAIN_BRANCH.equals(branch)
+        && table.snapshot(branch) == null) {
+      branch = null;
+    }
+
+    Snapshot headSnapshot = SnapshotUtil.latestSnapshot(table, branch);
+
     switch (scanContext.streamingStartingStrategy()) {
       case TABLE_SCAN_THEN_INCREMENTAL:
       case INCREMENTAL_FROM_LATEST_SNAPSHOT:
       case INCREMENTAL_FROM_LATEST_SNAPSHOT_EXCLUSIVE:
-        return Optional.ofNullable(table.currentSnapshot());
+        return Optional.ofNullable(headSnapshot);

Review Comment:
   Good point 👍 . Added tests.



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

Reply via email to