rdblue commented on a change in pull request #675: Inherit snapshot ids for 
manifest entries
URL: https://github.com/apache/incubator-iceberg/pull/675#discussion_r370754791
 
 

 ##########
 File path: core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java
 ##########
 @@ -129,17 +134,23 @@ public RewriteManifests deleteManifest(ManifestFile 
manifest) {
 
   @Override
   public RewriteManifests addManifest(ManifestFile manifest) {
-    try {
-      // the appended manifest must be rewritten with this update's snapshot ID
-      addedManifests.add(copyManifest(manifest));
-    } catch (IllegalArgumentException e) {
-      throw new IllegalArgumentException("Cannot append manifest: " + 
e.getMessage());
+    Preconditions.checkArgument(!manifest.hasAddedFiles(), "Cannot add 
manifest with added files");
+    Preconditions.checkArgument(!manifest.hasDeletedFiles(), "Cannot add 
manifest with deleted files");
+    Preconditions.checkArgument(manifest.snapshotId() == null, "Snapshot id 
must be assigned during commit");
 
 Review comment:
   I think this should allow snapshots with ID -1 as well. Previously, we used 
-1 when the snapshot ID was not set. While it is safe for this to check for 
null because `ManifestWriter` now produces only snapshots with a valid ID or 
null, there are situations where manifests were written with a previous version 
of Iceberg and then are committed with this version. Those manifests would be 
rejected. Our Flink writer appends manifests that are written like this, so 
when the application restarts, it may try to append a manifest written in the 
checkpoint committed prior to the application starting with the new version.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to