Skip to content

Commit c7de6cb

Browse files
authoredJun 7, 2024
Core: Reword exception message in RewriteManifests validation (apache#10446)
1 parent e0dc57e commit c7de6cb

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
 

‎core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public List<ManifestFile> apply(TableMetadata base, Snapshot snapshot) {
171171
List<ManifestFile> currentManifests = base.currentSnapshot().allManifests(ops.io());
172172
Set<ManifestFile> currentManifestSet = ImmutableSet.copyOf(currentManifests);
173173

174-
validateDeletedManifests(currentManifestSet);
174+
validateDeletedManifests(currentManifestSet, base.currentSnapshot().snapshotId());
175175

176176
if (requiresRewrite(currentManifestSet)) {
177177
performRewrite(currentManifests);
@@ -275,14 +275,17 @@ private boolean matchesPredicate(ManifestFile manifest) {
275275
return predicate == null || predicate.test(manifest);
276276
}
277277

278-
private void validateDeletedManifests(Set<ManifestFile> currentManifests) {
278+
private void validateDeletedManifests(
279+
Set<ManifestFile> currentManifests, long currentSnapshotID) {
279280
// directly deleted manifests must be still present in the current snapshot
280281
deletedManifests.stream()
281282
.filter(manifest -> !currentManifests.contains(manifest))
282283
.findAny()
283284
.ifPresent(
284285
manifest -> {
285-
throw new ValidationException("Manifest is missing: %s", manifest.path());
286+
throw new ValidationException(
287+
"Deleted manifest %s could not be found in the latest snapshot %d",
288+
manifest.path(), currentSnapshotID);
286289
});
287290
}
288291

‎core/src/test/java/org/apache/iceberg/TestRewriteManifests.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,10 @@ public void testManifestReplacementConcurrentConflictingDelete() throws IOExcept
810810

811811
assertThatThrownBy(rewriteManifests::commit)
812812
.isInstanceOf(ValidationException.class)
813-
.hasMessageStartingWith("Manifest is missing");
813+
.hasMessageStartingWith(
814+
String.format(
815+
"Deleted manifest %s could not be found in the latest snapshot %d",
816+
firstSnapshotManifest.path(), table.currentSnapshot().snapshotId()));
814817
}
815818

816819
@TestTemplate
@@ -1604,7 +1607,10 @@ public void testDeleteManifestReplacementConflictingDeleteFileRemoval() throws I
16041607
// the rewrite must fail as the original delete manifest was replaced concurrently
16051608
assertThatThrownBy(rewriteManifests::commit)
16061609
.isInstanceOf(ValidationException.class)
1607-
.hasMessageStartingWith("Manifest is missing");
1610+
.hasMessageStartingWith(
1611+
String.format(
1612+
"Deleted manifest %s could not be found in the latest snapshot %d",
1613+
originalDeleteManifest.path(), table.currentSnapshot().snapshotId()));
16081614
}
16091615

16101616
@TestTemplate

0 commit comments

Comments
 (0)