timothyw553 commented on code in PR #19099:
URL: https://github.com/apache/iceberg/pull/19099#discussion_r4728049051
##########
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:
for `INCREMENTAL_FROM_SNAPSHOT_ID`,
`table.snapshot(scanContext.startSnapshotId())` doesn't check whether that
snapshot is actually in `branch`'s history. should we reject snapshots outside
the branch at startup (with tests for both a fork-parent child on `main` and a
deeper `main` snapshot), or track that in a follow-up?
--
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]