anoopj commented on code in PR #19007:
URL: https://github.com/apache/iceberg/pull/19007#discussion_r4747027237


##########
core/src/main/java/org/apache/iceberg/V4ManifestWriter.java:
##########
@@ -170,30 +184,59 @@ public void appendAtSeq(TrackedFile file, long 
dataSequenceNumber) {
   }
 
   public void modify(TrackedFile file, DeletionVector dv) {
+    Preconditions.checkArgument(
+        file.contentType() == FileContent.DATA,
+        "Cannot modify %s file with a data DV: %s",
+        file.contentType(),
+        file.location());
+
     TrackingBuilder modified = TrackingBuilder.from(file.tracking(), 
snapshotId).dvUpdated();
-    TrackedFile withNewDV = Delegates.withDV(file, dv);
+    TrackedFile withNewDV = Delegates.withDataDV(file, dv);
     write(withNewDV, modified.build());
   }
 
   public void existing(TrackedFile file) {
+    Preconditions.checkArgument(
+        file.contentType() == FileContent.DATA
+            || file.contentType() == FileContent.DATA_MANIFEST
+            || file.contentType() == FileContent.DELETE_MANIFEST,
+        "Cannot add existing %s file: %s",
+        file.contentType(),
+        file.location());
+
     Tracking existing = TrackingBuilder.from(file.tracking(), 
snapshotId).build();
     write(file, existing);
   }
 
   public void replace(TrackedFile file) {
+    Preconditions.checkArgument(
+        file.contentType() == FileContent.DATA || file.contentType() == 
FileContent.DATA_MANIFEST,
+        "Cannot replace %s file: %s",
+        file.contentType(),
+        file.location());
+

Review Comment:
   We only allow `REPLACED` for data files, and a data manifest that was 
modified only has the `MODIFIED` entry (with bitmaps populated). This allows 
`REPLACED` status for leaf manifests - should we just be rejecting them 
instead? If that is the case, we can drop the test `rootManifestFileReplace` as 
well. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to