RussellSpitzer commented on code in PR #12855: URL: https://github.com/apache/iceberg/pull/12855#discussion_r2075783300
########## data/src/test/java/org/apache/iceberg/data/DeleteReadTests.java: ########## @@ -586,6 +595,94 @@ public void testEqualityDeleteByNull() throws IOException { checkDeleteCount(1L); } + @TestTemplate + public void testEqualityDeleteBinaryColumn() throws IOException { + List<Record> allRecords = appendOptionalColumnRecords(); + + Record binaryDataDelete = GenericRecord.create(table.schema().select("binaryData")); + List<Record> equalityDeletes = + Lists.newArrayList( + binaryDataDelete.copy("binaryData", ByteBuffer.wrap(("binaryData_0").getBytes())), + binaryDataDelete.copy("binaryData", ByteBuffer.wrap(("binaryData_1").getBytes())), + binaryDataDelete.copy("binaryData", ByteBuffer.wrap(("binaryData_2").getBytes()))); + StructLikeSet expected = rowSetWithoutIds(table, allRecords, 200, 201, 202); + testEqualityDeletes(equalityDeletes, expected); + } + + @TestTemplate + public void testEqualityDeleteStructColumn() throws IOException { + List<Record> allRecords = appendOptionalColumnRecords(); + + Record structDataDelete = GenericRecord.create(table.schema().select("structData")); + Record structRecord0 = + GenericRecord.create(table.schema().findType("structData").asStructType()); + Record structRecord1 = + GenericRecord.create(table.schema().findType("structData").asStructType()); + Record structRecord2 = + GenericRecord.create(table.schema().findType("structData").asStructType()); + structRecord0.setField("structInnerData", "structInnerData_0"); + structRecord1.setField("structInnerData", "structInnerData_1"); + structRecord2.setField("structInnerData", "structInnerData_2"); + List<Record> equalityDeletes = + Lists.newArrayList( + structDataDelete.copy("structData", structRecord0), + structDataDelete.copy("structData", structRecord1), + structDataDelete.copy("structData", structRecord2)); + StructLikeSet expected = rowSetWithoutIds(table, allRecords, 200, 201, 202); + testEqualityDeletes(equalityDeletes, expected); + } + + private void testEqualityDeletes(List<Record> equalityDeletes, StructLikeSet expected) + throws IOException { + if (equalityDeletes.isEmpty()) { + throw new IllegalArgumentException("Expected equality deletes in testEqualityDeletes"); + } + DeleteFile eqDeletes = + FileHelpers.writeDeleteFile( + table, + Files.localOutput(File.createTempFile("junit", null, temp.toFile())), + Row.of(0), + equalityDeletes, + equalityDeletes.get(0).struct().asSchema()); + table.newRowDelta().addDeletes(eqDeletes).commit(); + + StructLikeSet actual = rowSet(tableName, table, "*"); + assertThat(actual).as("Table should contain expected rows").isEqualTo(expected); + checkDeleteCount(equalityDeletes.size()); + } + + private List<Record> appendOptionalColumnRecords() throws IOException { Review Comment: I see this is basically the same as the "beforeEach" writeTestDataFile but just including the new columns you add ed to the schema. I think we should probably mimic that name as well writeOptionalTestDataFile or something like that. -- 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