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


##########
core/src/main/java/org/apache/iceberg/V4ManifestWriter.java:
##########
@@ -362,7 +403,14 @@ protected StructLike prepare(TrackedFile file, Tracking 
tracking) {
 
     @Override
     public long assignedRowIds() {
-      return nextRowId - firstRowId;
+      long assignedRowIds = nextRowId - firstRowId;
+      // sanity check the assigned row IDs
+      Preconditions.checkState(
+          assignedRowIds == super.assignedRowIds(),
+          "Incorrect assigned row IDs: %s != %s",
+          assignedRowIds,

Review Comment:
   Is the override needed? `super.assignedRowIds()` already tracks the same 
total, so we can drop it along with `firstRowId`. 
   
   If it stays, the 2nd arg in the error msg is wrong: it prints `nextRowId`, 
but the check compares against `super.assignedRowIds()`.
   



##########
core/src/main/java/org/apache/iceberg/V4ManifestWriter.java:
##########
@@ -170,30 +182,59 @@ public void appendAtSeq(TrackedFile file, long 
dataSequenceNumber) {
   }
 
   public void modify(TrackedFile file, DeletionVector dv) {
+    Preconditions.checkArgument(
+        file.contentType() == FileContent.DATA || file.contentType() == 
FileContent.DATA_MANIFEST,
+        "Cannot modify %s file: %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 modify %s file: %s",

Review Comment:
   typo: This is `existing()`, but the message says "Cannot modify".



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