Skip to content

Commit

Permalink
[core] Fix that batch unaware bucket compact cannot stop when there i…
Browse files Browse the repository at this point in the history
…s no snapshot (#4539)
  • Loading branch information
yuzelin authored Nov 18, 2024
1 parent d3384ac commit 203db41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ private void assignNewIterator() {
if (nextSnapshot == null) {
nextSnapshot = snapshotManager.latestSnapshotId();
if (nextSnapshot == null) {
if (!streamingMode) {
throw new EndOfScanException();
}
return;
}
snapshotReader.withMode(ScanMode.ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.table.FileStoreTable;
import org.apache.paimon.table.FileStoreTableFactory;
import org.apache.paimon.table.source.EndOfScanException;
import org.apache.paimon.types.DataTypes;

import org.junit.jupiter.api.BeforeEach;
Expand All @@ -43,7 +44,9 @@

import static org.apache.paimon.mergetree.compact.MergeTreeCompactManagerTest.row;
import static org.apache.paimon.stats.StatsTestUtils.newSimpleStats;
import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/** Tests for {@link UnawareAppendTableCompactionCoordinator}. */
public class UnawareAppendTableCompactionCoordinatorTest {
Expand Down Expand Up @@ -135,6 +138,14 @@ public void testAgeGrowUp() {
.isEqualTo(0);
}

@Test
public void testBatchScanEmptyTable() {
compactionCoordinator =
new UnawareAppendTableCompactionCoordinator(appendOnlyFileStoreTable, false);
assertThatThrownBy(() -> compactionCoordinator.scan())
.satisfies(anyCauseMatches(EndOfScanException.class));
}

private void assertTasks(List<DataFileMeta> files, int taskNum) {
compactionCoordinator.notifyNewFiles(partition, files);
List<UnawareAppendCompactionTask> tasks = compactionCoordinator.compactPlan();
Expand Down

0 comments on commit 203db41

Please sign in to comment.