JeonDaehong commented on code in PR #18993:
URL: https://github.com/apache/iceberg/pull/18993#discussion_r4599963181


##########
core/src/main/java/org/apache/iceberg/MergingSnapshotProducer.java:
##########
@@ -303,13 +303,24 @@ private static void 
validateDeleteFileForVersion(DeleteFile file, int formatVers
             ContentFileUtil.dvDesc(file));
         break;
       case 3:
-      case 4:
         Preconditions.checkArgument(
             file.content() == FileContent.EQUALITY_DELETES || 
ContentFileUtil.isDV(file),
             "Must use DVs for position deletes in V%s: %s",
             formatVersion,
             file.location());
         break;
+      case 4:
+        Preconditions.checkArgument(

Review Comment:
   `BaseRewriteFiles.addFile(DeleteFile)` goes through `add()` and this check 
too, so on an upgraded v4 table, rewriting existing equality deletes into new 
equality delete files is rejected as well. That reads like what the spec 
intends, but a `TestRewriteFiles` case would make it explicit.



##########
core/src/test/java/org/apache/iceberg/TestRowDelta.java:
##########
@@ -2558,6 +2562,69 @@ public void testInabilityToAddDVToV2Tables() {
         .hasMessageContaining("Must not use DVs for position deletes in V2");
   }
 
+  @TestTemplate
+  public void testInabilityToAddEqualityDeletesInV4() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(4);
+    assertThatThrownBy(() -> 
table.newRowDelta().addDeletes(FILE_A_EQUALITY_DELETES))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage(
+            "Cannot add equality deletes in V%s: %s",
+            formatVersion, FILE_A_EQUALITY_DELETES.location());
+  }
+
+  @TestTemplate
+  public void testV3StagedEqualityDeleteCannotCommitToV4() {

Review Comment:
   Nice that this covers the buffered path too: a delete staged on v3 is 
checked again in `validateDeleteFilesForVersion` when the commit lands on v4.



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