You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "dramaticlly (via GitHub)" <gi...@apache.org> on 2023/01/27 19:27:41 UTC
[GitHub] [iceberg] dramaticlly commented on a diff in pull request #6680: Core: DeleteWithFilter fails on HashCode Collision
dramaticlly commented on code in PR #6680:
URL: https://github.com/apache/iceberg/pull/6680#discussion_r1089341074
##########
core/src/test/java/org/apache/iceberg/TestDeleteFiles.java:
##########
@@ -349,6 +352,54 @@ 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());
+
+ Metrics metrics = new Metrics(1L, null, null, null, null);
+
+ DataFile testFileOne =
+ DataFiles.builder(spec)
+ .withPartition(partitionOne)
+ .withPath("/g1.parquet")
+ .withFileSizeInBytes(100)
+ .withMetrics(metrics)
+ .build();
+ DataFile testFileTwo =
+ DataFiles.builder(spec)
+ .withPartition(partitionTwo)
+ .withMetrics(metrics)
+ .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());
+
+ collisionTable.newDelete().deleteFromRowFilter(Expressions.equal("x", "BB")).commit();
+
+ Assert.assertEquals(
+ "We should have deleted one of them",
+ 1,
+ Lists.newArrayList(collisionTable.newScan().planFiles().iterator()).size());
Review Comment:
nit: might be a bit redundant, but I am curious if we shall verify the remaining files is correct and we deleted the desired partition instead?
I am thinking about maybe something like
```java
Assert.assertEquals(
partitionOne,
collisionTable.newScan().planFiles().iterator().next().file().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