Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,7 @@ private List<FileScanTask> planFiles(StreamingOffset startOffset, StreamingOffse

Snapshot snapshot = table.snapshot(currentOffset.snapshotId());

if (snapshot == null) {
throw new IllegalStateException(
String.format(
"Cannot load current offset at snapshot %d, the snapshot was expired or removed",
currentOffset.snapshotId()));
}
validateCurrentSnapshotExists(snapshot, currentOffset);

if (!shouldProcess(snapshot)) {
LOG.debug("Skipping snapshot: {} of table {}", currentOffset.snapshotId(), table.name());
Expand Down Expand Up @@ -340,6 +335,8 @@ public Offset latestOffset(Offset startOffset, ReadLimit limit) {
}

Snapshot curSnapshot = table.snapshot(startingOffset.snapshotId());
validateCurrentSnapshotExists(curSnapshot, startingOffset);

int startPosOfSnapOffset = (int) startingOffset.position();

boolean scanAllFiles = startingOffset.shouldScanAllFiles();
Expand Down Expand Up @@ -419,6 +416,15 @@ private long addedFilesCount(Snapshot snapshot) {
: addedFilesCount;
}

private void validateCurrentSnapshotExists(Snapshot snapshot, StreamingOffset currentOffset) {
if (snapshot == null) {
throw new IllegalStateException(
String.format(
"Cannot load current offset at snapshot %d, the snapshot was expired or removed",
currentOffset.snapshotId()));
}
}

@Override
public ReadLimit getDefaultReadLimit() {
if (maxFilesPerMicroBatch != Integer.MAX_VALUE
Expand Down