Skip to content
Merged
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 @@ -167,7 +167,8 @@ public void testTableCleanup() throws IOException {
taskEntity2 -> taskEntity2.getTaskType())
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier, List.of(statisticsFile.path())),
tableIdentifier,
List.of(snapshot.manifestListLocation(), statisticsFile.path())),
entity ->
entity.readData(
ManifestFileCleanupTaskHandler.ManifestCleanupTask.class)));
Expand Down Expand Up @@ -224,7 +225,7 @@ public void close() {
.getOrCreateMetaStoreManager(realmContext)
.loadTasks(callContext.getPolarisCallContext(), "test", 5)
.getEntities())
.hasSize(1);
.hasSize(2);
}

@Test
Expand Down Expand Up @@ -285,15 +286,41 @@ public void close() {
.getOrCreateMetaStoreManager(realmContext)
.loadTasks(callContext.getPolarisCallContext(), "test", 5)
.getEntities())
.hasSize(2)
.hasSize(4)
.satisfiesExactly(
taskEntity ->
assertThat(taskEntity)
.returns(PolarisEntityType.TASK.getCode(), PolarisBaseEntity::getTypeCode)
.extracting(TaskEntity::of)
.returns(
AsyncTaskType.MANIFEST_FILE_CLEANUP,
AsyncTaskType.METADATA_FILE_BATCH_CLEANUP,
taskEntity1 -> taskEntity1.getTaskType())
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier, List.of(snapshot.manifestListLocation())),
entity ->
entity.readData(
ManifestFileCleanupTaskHandler.ManifestCleanupTask.class)),
taskEntity ->
assertThat(taskEntity)
.returns(PolarisEntityType.TASK.getCode(), PolarisBaseEntity::getTypeCode)
.extracting(TaskEntity::of)
.returns(
AsyncTaskType.METADATA_FILE_BATCH_CLEANUP,
taskEntity2 -> taskEntity2.getTaskType())
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier, List.of(snapshot.manifestListLocation())),
entity ->
entity.readData(
ManifestFileCleanupTaskHandler.ManifestCleanupTask.class)),
taskEntity ->
assertThat(taskEntity)
.returns(PolarisEntityType.TASK.getCode(), PolarisBaseEntity::getTypeCode)
.extracting(TaskEntity::of)
.returns(
AsyncTaskType.MANIFEST_FILE_CLEANUP,
taskEntity3 -> taskEntity3.getTaskType())
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier,
Expand All @@ -307,7 +334,7 @@ public void close() {
.extracting(TaskEntity::of)
.returns(
AsyncTaskType.MANIFEST_FILE_CLEANUP,
taskEntity2 -> taskEntity2.getTaskType())
taskEntity4 -> taskEntity4.getTaskType())
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier,
Expand Down Expand Up @@ -413,7 +440,11 @@ public void testTableCleanupMultipleSnapshots() throws IOException {
.returns(
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier,
List.of(statisticsFile1.path(), statisticsFile2.path())),
List.of(
snapshot.manifestListLocation(),
snapshot2.manifestListLocation(),
statisticsFile1.path(),
statisticsFile2.path())),
entity ->
entity.readData(
ManifestFileCleanupTaskHandler.ManifestCleanupTask.class)));
Expand Down Expand Up @@ -569,7 +600,11 @@ public void testTableCleanupMultipleMetadata() throws IOException {
new ManifestFileCleanupTaskHandler.ManifestCleanupTask(
tableIdentifier,
List.of(
firstMetadataFile, statisticsFile1.path(), statisticsFile2.path())),
firstMetadataFile,
snapshot.manifestListLocation(),
snapshot2.manifestListLocation(),
statisticsFile1.path(),
statisticsFile2.path())),
entity ->
entity.readData(
ManifestFileCleanupTaskHandler.ManifestCleanupTask.class)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.iceberg.ManifestFile;
import org.apache.iceberg.Snapshot;
import org.apache.iceberg.StatisticsFile;
import org.apache.iceberg.TableMetadata;
import org.apache.iceberg.TableMetadataParser;
Expand Down Expand Up @@ -243,7 +244,10 @@ private List<List<String>> getMetadataFileBatches(TableMetadata tableMetadata, i
List<List<String>> result = new ArrayList<>();
List<String> metadataFiles =
Stream.concat(
tableMetadata.previousFiles().stream().map(TableMetadata.MetadataLogEntry::file),
Stream.concat(
tableMetadata.previousFiles().stream()
.map(TableMetadata.MetadataLogEntry::file),
tableMetadata.snapshots().stream().map(Snapshot::manifestListLocation)),
tableMetadata.statisticsFiles().stream().map(StatisticsFile::path))
.toList();

Expand Down