Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark: Fix failing SS UT #7414

Merged
merged 1 commit into from
Apr 23, 2023
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