Skip to content

Commit 5912639

Browse files
committed
fix
1 parent 83df9c9 commit 5912639

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,12 @@ protected Runnable newExpireRunnable() {
477477

478478
private Optional<TableSchema> tryTimeTravel(Options options) {
479479
CoreOptions coreOptions = new CoreOptions(options);
480-
Snapshot snapshot =
481-
TimeTravelUtil.resolveSnapshotFromOptions(coreOptions, snapshotManager());
480+
Snapshot snapshot;
481+
try {
482+
snapshot = TimeTravelUtil.resolveSnapshotFromOptions(coreOptions, snapshotManager());
483+
} catch (Exception e) {
484+
return Optional.empty();
485+
}
482486
if (snapshot == null) {
483487
return Optional.empty();
484488
}

paimon-core/src/test/java/org/apache/paimon/table/system/ManifestsTableTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import static org.apache.paimon.SnapshotTest.newSnapshotManager;
4848
import static org.apache.paimon.utils.FileStorePathFactoryTest.createNonPartFactory;
4949
import static org.assertj.core.api.Assertions.assertThat;
50+
import static org.junit.jupiter.api.Assertions.assertThrows;
5051

5152
/** Unit tests for {@link ManifestsTable}. */
5253
public class ManifestsTableTest extends TableTestBase {
@@ -148,6 +149,18 @@ public void testReadManifestsFromSpecifiedTimestampMillis() throws Exception {
148149
assertThat(result).containsExactlyElementsOf(expectedRow);
149150
}
150151

152+
@Test
153+
public void testReadManifestsFromNotExistSnapshot() {
154+
manifestsTable =
155+
(ManifestsTable)
156+
manifestsTable.copy(
157+
Collections.singletonMap(CoreOptions.SCAN_SNAPSHOT_ID.key(), "3"));
158+
assertThrows(
159+
Exception.class,
160+
() -> read(manifestsTable),
161+
"Specified parameter scan.snapshot-id = 3 is not exist, you can set it in range from 1 to 2");
162+
}
163+
151164
private List<InternalRow> getExpectedResult(long snapshotId) {
152165
if (!snapshotManager.snapshotExists(snapshotId)) {
153166
return Collections.emptyList();

0 commit comments

Comments
 (0)