Skip to content
Open
Show file tree
Hide file tree
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 @@ -377,6 +377,25 @@ public void testChangelogWithScanStartupMode() throws Exception {
.containsExactlyInAnyOrder(
"+I[+I, 3, 1970-01-01T00:00:00.200Z, 4, v4]",
"+I[+I, 4, 1970-01-01T00:00:00.200Z, 5, v5]");

// 3. Test scan.startup.mode='latest' - should only read new records after subscription
String optionsLatest = " /*+ OPTIONS('scan.startup.mode' = 'latest') */";
String queryLatest = "SELECT id FROM startup_mode_test$changelog" + optionsLatest;
CloseableIterator<Row> rowIterLatest = tEnv.executeSql(queryLatest).collect();
List<String> latestResults = new ArrayList<>();
for (int attempt = 0; attempt < 10; attempt++) {
// Write a new record (with id larger than 5)
int rowId = 6 + attempt;
writeRows(conn, tablePath, Arrays.asList(row(rowId, "v" + rowId)), false);

// Try to fetch one record with a 5-second timeout
latestResults = collectRowsWithTimeout(rowIterLatest, 1, Duration.ofSeconds(5));
if (!latestResults.isEmpty()) {
break;
}
}
int id = Integer.parseInt(latestResults.getFirst().replaceAll(".*\\[(\\d+)]", "$1"));
assertThat(id).isGreaterThan(5);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public static List<String> collectRowsWithTimeout(
return collectRowsWithTimeout(iterator, expectedCount, true);
}

public static List<String> collectRowsWithTimeout(
CloseableIterator<Row> iterator, int expectedCount, Duration maxWaitTime) {
return collectRowsWithTimeout(iterator, expectedCount, true, maxWaitTime);
}

public static List<String> collectRowsWithTimeout(
CloseableIterator<Row> iterator, int expectedCount, boolean closeIterator) {
if (expectedCount < 0) {
Expand Down