nastra commented on code in PR #13425:
URL: https://github.com/apache/iceberg/pull/13425#discussion_r2189467459


##########
core/src/test/java/org/apache/iceberg/PartitionStatsHandlerTestBase.java:
##########
@@ -641,6 +672,47 @@ public void testFullComputeFallbackWithInvalidStats() 
throws Exception {
     assertThat(partitionStats.get(0).dataFileCount()).isEqualTo(2);
   }
 
+  @Test
+  public void testV2toV3SchemaEvolution() throws Exception {
+    Table testTable =
+        TestTables.create(
+            tempDir("schema_evolution"), "schema_evolution", SCHEMA, SPEC, 2, 
fileFormatProperty);
+
+    // write stats file using v2 schema
+    DataFile dataFile =
+        FileGenerationUtil.generateDataFile(testTable, 
TestHelpers.Row.of("foo", "A"));
+    testTable.newAppend().appendFile(dataFile).commit();
+    PartitionStatisticsFile statisticsFile =
+        PartitionStatsHandler.computeAndWriteStatsFile(
+            testTable, testTable.currentSnapshot().snapshotId());
+
+    Types.StructType partitionSchema = Partitioning.partitionType(testTable);
+
+    // read with v2 schema
+    Schema v2Schema = PartitionStatsHandler.schema(partitionSchema, 2);
+    List<PartitionStats> partitionStatsV2;
+    try (CloseableIterable<PartitionStats> recordIterator =
+        PartitionStatsHandler.readPartitionStatsFile(
+            v2Schema, testTable.io().newInputFile(statisticsFile.path()))) {
+      partitionStatsV2 = Lists.newArrayList(recordIterator);
+    }
+
+    // read with v3 schema
+    Schema v3Schema = PartitionStatsHandler.schema(partitionSchema, 3);
+    List<PartitionStats> partitionStatsV3;
+    try (CloseableIterable<PartitionStats> recordIterator =
+        PartitionStatsHandler.readPartitionStatsFile(
+            v3Schema, testTable.io().newInputFile(statisticsFile.path()))) {
+      partitionStatsV3 = Lists.newArrayList(recordIterator);
+    }
+
+    assertThat(partitionStatsV2).hasSize(partitionStatsV3.size());

Review Comment:
   ```suggestion
       assertThat(partitionStatsV2).hasSameSizeAs(partitionStatsV3);
   ```



-- 
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]

Reply via email to