You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "stevenzwu (via GitHub)" <gi...@apache.org> on 2023/01/28 04:53:03 UTC

[GitHub] [iceberg] stevenzwu commented on a diff in pull request #6680: Core: DeleteWithFilter fails on HashCode Collision

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


##########
core/src/test/java/org/apache/iceberg/TestDeleteFiles.java:
##########
@@ -349,6 +355,56 @@ public void testDeleteFilesOnIndependentBranches() {
         statuses(Status.EXISTING, Status.DELETED, Status.DELETED));
   }
 
+  @Test
+  public void testDeleteWithCollision() {
+    Schema schema = new Schema(Types.NestedField.of(0, false, "x", Types.StringType.get()));
+    PartitionSpec spec = PartitionSpec.builderFor(schema).identity("x").build();
+    Table collisionTable =
+        TestTables.create(tableDir, "hashcollision", schema, spec, formatVersion);
+
+    PartitionData partitionOne = new PartitionData(spec.partitionType());
+    partitionOne.set(0, "Aa");
+    PartitionData partitionTwo = new PartitionData(spec.partitionType());
+    partitionTwo.set(0, "BB");
+
+    Assert.assertEquals(
+        StructLikeWrapper.forType(spec.partitionType()).set(partitionOne).hashCode(),
+        StructLikeWrapper.forType(spec.partitionType()).set(partitionTwo).hashCode());
+
+    DataFile testFileOne =
+        DataFiles.builder(spec)
+            .withPartition(partitionOne)
+            .withPath("/g1.parquet")
+            .withFileSizeInBytes(100)
+            .withRecordCount(1)
+            .build();
+
+    DataFile testFileTwo =
+        DataFiles.builder(spec)
+            .withPartition(partitionTwo)
+            .withRecordCount(1)
+            .withFileSizeInBytes(100)
+            .withPath("/g2.parquet")
+            .build();
+
+    collisionTable.newFastAppend().appendFile(testFileOne).appendFile(testFileTwo).commit();
+
+    Assert.assertEquals(
+        "We should have two files",
+        2,
+        Lists.newArrayList(collisionTable.newScan().planFiles().iterator()).size());

Review Comment:
   nit: maybe assert on two partitions here? correspond to the assertion after deletion that there is only one partition.



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org