rdblue commented on code in PR #5795:
URL: https://github.com/apache/iceberg/pull/5795#discussion_r982951076
##########
spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/actions/TestRemoveOrphanFilesAction.java:
##########
@@ -876,6 +890,82 @@ protected long waitUntilAfter(long timestampMillis) {
return current;
}
+ @Test
+ public void testRemoveOrphanFilesWithStatisticFiles() throws Exception {
+ Table table =
+ TABLES.create(
+ SCHEMA,
+ PartitionSpec.unpartitioned(),
+ ImmutableMap.of(TableProperties.FORMAT_VERSION, "2"),
+ tableLocation);
+
+ List<ThreeColumnRecord> records =
+ Lists.newArrayList(new ThreeColumnRecord(1, "AAAAAAAAAA", "AAAA"));
+ Dataset<Row> df = spark.createDataFrame(records,
ThreeColumnRecord.class).coalesce(1);
+ df.select("c1", "c2",
"c3").write().format("iceberg").mode("append").save(tableLocation);
+
+ table.refresh();
+ long snapshotId = table.currentSnapshot().snapshotId();
+ long snapshotSequenceNumber = table.currentSnapshot().sequenceNumber();
+
+ File statsLocation =
+ new File(new URI(tableLocation))
+ .toPath()
+ .resolve("data")
+ .resolve("some-stats-file")
+ .toFile();
+ StatisticsFile statisticsFile;
+ try (PuffinWriter puffinWriter =
Puffin.write(Files.localOutput(statsLocation)).build()) {
+ puffinWriter.add(
+ new Blob(
+ "some-blob-type",
+ ImmutableList.of(1),
+ snapshotId,
+ snapshotSequenceNumber,
+ ByteBuffer.wrap("blob
content".getBytes(StandardCharsets.UTF_8))));
+ puffinWriter.finish();
+ statisticsFile =
+ new GenericStatisticsFile(
Review Comment:
Can `PuffinWriter` expose `toStatisticsFile` instead of relying on the
caller to do this work?
--
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]