|
44 | 44 | import org.junit.jupiter.api.Test;
|
45 | 45 | import org.junit.jupiter.api.extension.RegisterExtension;
|
46 | 46 | import org.junit.jupiter.api.io.TempDir;
|
| 47 | +import org.junit.jupiter.params.ParameterizedTest; |
| 48 | +import org.junit.jupiter.params.provider.EnumSource; |
47 | 49 |
|
48 | 50 | public class TestContinuousSplitPlannerImpl {
|
49 | 51 | @TempDir protected Path temporaryFolder;
|
@@ -173,13 +175,14 @@ public void testTableScanThenIncrementalWithNonEmptyTable() throws Exception {
|
173 | 175 | }
|
174 | 176 | }
|
175 | 177 |
|
176 |
| - @Test |
177 |
| - public void testIncrementalFromLatestSnapshotWithEmptyTable() throws Exception { |
| 178 | + @ParameterizedTest |
| 179 | + @EnumSource( |
| 180 | + value = StreamingStartingStrategy.class, |
| 181 | + names = {"INCREMENTAL_FROM_LATEST_SNAPSHOT", "INCREMENTAL_FROM_LATEST_SNAPSHOT_EXCLUSIVE"}) |
| 182 | + public void testIncrementalFromLatestSnapshotWithEmptyTable( |
| 183 | + StreamingStartingStrategy startingStrategy) throws Exception { |
178 | 184 | ScanContext scanContext =
|
179 |
| - ScanContext.builder() |
180 |
| - .startingStrategy(StreamingStartingStrategy.INCREMENTAL_FROM_LATEST_SNAPSHOT) |
181 |
| - .splitSize(1L) |
182 |
| - .build(); |
| 185 | + ScanContext.builder().startingStrategy(startingStrategy).splitSize(1L).build(); |
183 | 186 | ContinuousSplitPlannerImpl splitPlanner =
|
184 | 187 | new ContinuousSplitPlannerImpl(TABLE_RESOURCE.tableLoader().clone(), scanContext, null);
|
185 | 188 |
|
@@ -256,6 +259,44 @@ public void testIncrementalFromLatestSnapshotWithNonEmptyTable() throws Exceptio
|
256 | 259 | }
|
257 | 260 | }
|
258 | 261 |
|
| 262 | + @Test |
| 263 | + public void testIncrementalFromLatestSnapshotExclusiveWithNonEmptyTable() throws Exception { |
| 264 | + appendTwoSnapshots(); |
| 265 | + |
| 266 | + ScanContext scanContext = |
| 267 | + ScanContext.builder() |
| 268 | + .startingStrategy(StreamingStartingStrategy.INCREMENTAL_FROM_LATEST_SNAPSHOT_EXCLUSIVE) |
| 269 | + .build(); |
| 270 | + ContinuousSplitPlannerImpl splitPlanner = |
| 271 | + new ContinuousSplitPlannerImpl(TABLE_RESOURCE.tableLoader().clone(), scanContext, null); |
| 272 | + |
| 273 | + ContinuousEnumerationResult initialResult = splitPlanner.planSplits(null); |
| 274 | + assertThat(initialResult.splits()).isEmpty(); |
| 275 | + assertThat(initialResult.fromPosition()).isNull(); |
| 276 | + // For exclusive behavior, the initial result should point to snapshot2 |
| 277 | + assertThat(initialResult.toPosition().snapshotId().longValue()) |
| 278 | + .isEqualTo(snapshot2.snapshotId()); |
| 279 | + assertThat(initialResult.toPosition().snapshotTimestampMs().longValue()) |
| 280 | + .isEqualTo(snapshot2.timestampMillis()); |
| 281 | + |
| 282 | + // Then the next incremental scan shall discover no files |
| 283 | + ContinuousEnumerationResult secondResult = splitPlanner.planSplits(initialResult.toPosition()); |
| 284 | + assertThat(initialResult.splits()).isEmpty(); |
| 285 | + assertThat(secondResult.fromPosition().snapshotId().longValue()) |
| 286 | + .isEqualTo(snapshot2.snapshotId()); |
| 287 | + assertThat(secondResult.fromPosition().snapshotTimestampMs().longValue()) |
| 288 | + .isEqualTo(snapshot2.timestampMillis()); |
| 289 | + assertThat(secondResult.toPosition().snapshotId().longValue()) |
| 290 | + .isEqualTo(snapshot2.snapshotId()); |
| 291 | + assertThat(secondResult.toPosition().snapshotTimestampMs().longValue()) |
| 292 | + .isEqualTo(snapshot2.timestampMillis()); |
| 293 | + |
| 294 | + IcebergEnumeratorPosition lastPosition = secondResult.toPosition(); |
| 295 | + for (int i = 0; i < 3; ++i) { |
| 296 | + lastPosition = verifyOneCycle(splitPlanner, lastPosition).lastPosition; |
| 297 | + } |
| 298 | + } |
| 299 | + |
259 | 300 | @Test
|
260 | 301 | public void testIncrementalFromEarliestSnapshotWithEmptyTable() throws Exception {
|
261 | 302 | ScanContext scanContext =
|
|
0 commit comments