szehon-ho commented on code in PR #6680: URL: https://github.com/apache/iceberg/pull/6680#discussion_r1089519883
########## 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()); + + collisionTable.newDelete().deleteFromRowFilter(Expressions.equal("x", "BB")).commit(); + + List<StructLike> partitions = + Lists.newArrayList(collisionTable.newScan().planFiles().iterator()).stream() + .map(s -> ((PartitionData) s.partition()).copy()) + .collect(Collectors.toList()); + + Assert.assertEquals( + "We should have deleted partitionTwo of them", ImmutableList.of(partitionOne), partitions); Review Comment: Run on here? -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org