This is an automated email from the ASF dual-hosted git repository.

ashishkumar50 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 03ceafcb608 HDDS-15174. Add tests for Ozone Iceberg statistics file 
copy plan. (#10189)
03ceafcb608 is described below

commit 03ceafcb6085189cb4694a31f094226237ed94b6
Author: slfan1989 <[email protected]>
AuthorDate: Wed May 13 12:05:10 2026 +0800

    HDDS-15174. Add tests for Ozone Iceberg statistics file copy plan. (#10189)
---
 .../iceberg/TestRewriteTablePathOzoneAction.java   | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git 
a/hadoop-ozone/iceberg/src/test/java/org/apache/hadoop/ozone/iceberg/TestRewriteTablePathOzoneAction.java
 
b/hadoop-ozone/iceberg/src/test/java/org/apache/hadoop/ozone/iceberg/TestRewriteTablePathOzoneAction.java
index 56442a75063..35bab0df55a 100644
--- 
a/hadoop-ozone/iceberg/src/test/java/org/apache/hadoop/ozone/iceberg/TestRewriteTablePathOzoneAction.java
+++ 
b/hadoop-ozone/iceberg/src/test/java/org/apache/hadoop/ozone/iceberg/TestRewriteTablePathOzoneAction.java
@@ -17,7 +17,9 @@
 
 package org.apache.hadoop.ozone.iceberg;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.BufferedReader;
@@ -36,6 +38,7 @@
 import org.apache.iceberg.FileFormat;
 import org.apache.iceberg.GenericManifestFile;
 import org.apache.iceberg.GenericPartitionFieldSummary;
+import org.apache.iceberg.GenericStatisticsFile;
 import org.apache.iceberg.HasTableOperations;
 import org.apache.iceberg.InternalData;
 import org.apache.iceberg.ManifestFile;
@@ -44,6 +47,7 @@
 import org.apache.iceberg.Schema;
 import org.apache.iceberg.Snapshot;
 import org.apache.iceberg.StaticTableOperations;
+import org.apache.iceberg.StatisticsFile;
 import org.apache.iceberg.Table;
 import org.apache.iceberg.TableMetadata;
 import org.apache.iceberg.TableMetadata.MetadataLogEntry;
@@ -202,6 +206,51 @@ void tablePathRewriteForStartAndEndVersionProvided() 
throws Exception {
     assertAllInternalPathsRewritten(csvPairs, targetPrefix);
   }
 
+  @Test
+  void statsFileCopyPlanReturnsEmptySetForEmptyStats() {
+    Set<Pair<String, String>> copyPlan =
+        RewriteTablePathOzoneUtils.statsFileCopyPlan(List.of(), List.of());
+
+    assertTrue(copyPlan.isEmpty());
+  }
+
+  @Test
+  void statsFileCopyPlanRejectsMismatchedStatsCount() {
+    IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class,
+        () -> RewriteTablePathOzoneUtils.statsFileCopyPlan(
+            List.of(statisticsFile("before-1.stats", 100)),
+            List.of()));
+
+    assertThat(exception)
+        .hasMessageContaining("Before and after path rewrite, statistic files 
count should be same");
+  }
+
+  @Test
+  void statsFileCopyPlanRejectsMismatchedStatsFileSize() {
+    IllegalArgumentException exception = 
assertThrows(IllegalArgumentException.class,
+        () -> RewriteTablePathOzoneUtils.statsFileCopyPlan(
+            List.of(statisticsFile("before-1.stats", 100)),
+            List.of(statisticsFile("after-1.stats", 200))));
+
+    assertThat(exception)
+        .hasMessageContaining("Before and after path rewrite, statistic files 
size should be same");
+  }
+
+  @Test
+  void statsFileCopyPlanReturnsBeforeToAfterPathPairs() {
+    Set<Pair<String, String>> copyPlan = 
RewriteTablePathOzoneUtils.statsFileCopyPlan(
+        List.of(
+            statisticsFile("before-1.stats", 100),
+            statisticsFile("before-2.stats", 200)),
+        List.of(
+            statisticsFile("after-1.stats", 100),
+            statisticsFile("after-2.stats", 200)));
+
+    assertEquals(Set.of(
+        Pair.of("before-1.stats", "after-1.stats"),
+        Pair.of("before-2.stats", "after-2.stats")), copyPlan);
+  }
+
   /**
    * For every staged file in the CSV copy plan, asserts that internal paths 
are rewritten
    * to the target prefix:
@@ -358,4 +407,8 @@ private DataFile dummyDataFile(String dataPath) {
         .withFormat(FileFormat.PARQUET)
         .build();
   }
+
+  private static StatisticsFile statisticsFile(String path, long 
fileSizeInBytes) {
+    return new GenericStatisticsFile(1L, path, fileSizeInBytes, 0L, List.of());
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to