This is an automated email from the ASF dual-hosted git repository.
amoghj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new c7de6cb345 Core: Reword exception message in RewriteManifests
validation (#10446)
c7de6cb345 is described below
commit c7de6cb345995cb47312edbef6edae2f17fb8aba
Author: Ajantha Bhat <[email protected]>
AuthorDate: Fri Jun 7 06:09:06 2024 +0530
Core: Reword exception message in RewriteManifests validation (#10446)
---
.../src/main/java/org/apache/iceberg/BaseRewriteManifests.java | 9 ++++++---
.../src/test/java/org/apache/iceberg/TestRewriteManifests.java | 10 ++++++++--
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java
b/core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java
index e8fbfef2ca..f3f8e5fcd7 100644
--- a/core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java
+++ b/core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java
@@ -171,7 +171,7 @@ public class BaseRewriteManifests extends
SnapshotProducer<RewriteManifests>
List<ManifestFile> currentManifests =
base.currentSnapshot().allManifests(ops.io());
Set<ManifestFile> currentManifestSet =
ImmutableSet.copyOf(currentManifests);
- validateDeletedManifests(currentManifestSet);
+ validateDeletedManifests(currentManifestSet,
base.currentSnapshot().snapshotId());
if (requiresRewrite(currentManifestSet)) {
performRewrite(currentManifests);
@@ -275,14 +275,17 @@ public class BaseRewriteManifests extends
SnapshotProducer<RewriteManifests>
return predicate == null || predicate.test(manifest);
}
- private void validateDeletedManifests(Set<ManifestFile> currentManifests) {
+ private void validateDeletedManifests(
+ Set<ManifestFile> currentManifests, long currentSnapshotID) {
// directly deleted manifests must be still present in the current snapshot
deletedManifests.stream()
.filter(manifest -> !currentManifests.contains(manifest))
.findAny()
.ifPresent(
manifest -> {
- throw new ValidationException("Manifest is missing: %s",
manifest.path());
+ throw new ValidationException(
+ "Deleted manifest %s could not be found in the latest
snapshot %d",
+ manifest.path(), currentSnapshotID);
});
}
diff --git a/core/src/test/java/org/apache/iceberg/TestRewriteManifests.java
b/core/src/test/java/org/apache/iceberg/TestRewriteManifests.java
index ef42fc1793..176f61079f 100644
--- a/core/src/test/java/org/apache/iceberg/TestRewriteManifests.java
+++ b/core/src/test/java/org/apache/iceberg/TestRewriteManifests.java
@@ -810,7 +810,10 @@ public class TestRewriteManifests extends TestBase {
assertThatThrownBy(rewriteManifests::commit)
.isInstanceOf(ValidationException.class)
- .hasMessageStartingWith("Manifest is missing");
+ .hasMessageStartingWith(
+ String.format(
+ "Deleted manifest %s could not be found in the latest snapshot
%d",
+ firstSnapshotManifest.path(),
table.currentSnapshot().snapshotId()));
}
@TestTemplate
@@ -1604,7 +1607,10 @@ public class TestRewriteManifests extends TestBase {
// the rewrite must fail as the original delete manifest was replaced
concurrently
assertThatThrownBy(rewriteManifests::commit)
.isInstanceOf(ValidationException.class)
- .hasMessageStartingWith("Manifest is missing");
+ .hasMessageStartingWith(
+ String.format(
+ "Deleted manifest %s could not be found in the latest snapshot
%d",
+ originalDeleteManifest.path(),
table.currentSnapshot().snapshotId()));
}
@TestTemplate