jiwen624 commented on code in PR #19099:
URL: https://github.com/apache/iceberg/pull/19099#discussion_r4729801005
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/source/enumerator/ContinuousSplitPlannerImpl.java:
##########
@@ -220,13 +220,21 @@ private ContinuousEnumerationResult
discoverInitialSplits() {
*/
@VisibleForTesting
static Optional<Snapshot> startSnapshot(Table table, ScanContext
scanContext) {
+ String branch = scanContext.branch();
+ if (branch != null && 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);
case INCREMENTAL_FROM_EARLIEST_SNAPSHOT:
- return Optional.ofNullable(SnapshotUtil.oldestAncestor(table));
+ return Optional.ofNullable(headSnapshot)
+ .map(snapshot -> SnapshotUtil.oldestAncestorOf(table,
snapshot.snapshotId()));
case INCREMENTAL_FROM_SNAPSHOT_ID:
Snapshot matchedSnapshotById =
table.snapshot(scanContext.startSnapshotId());
Review Comment:
Good point! 👍 I'd put it in a follow-up since it's out of the scope of this
fix. Also, the check would make some jobs that run today fail at startup so
ideally it should be in its own PR (and release notes too) so reviewers can
judge the behaviour change separately. Raised
https://github.com/apache/iceberg/issues/19171
--
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]