anuragmantri commented on code in PR #13881:
URL: https://github.com/apache/iceberg/pull/13881#discussion_r2291553407
##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java:
##########
@@ -963,6 +963,59 @@ public void testTableWithManyStatisticFiles() throws
IOException {
iterations * 2 + 1, iterations, iterations, iterations, iterations * 6
+ 1, result);
}
+ @Test
+ public void testStatisticsFileSourcePath() throws IOException {
+ String sourceTableLocation = newTableLocation();
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put("format-version", "2");
+ String tableName = "v2tblwithstats";
+ Table sourceTable =
+ createMetastoreTable(sourceTableLocation, properties, "default",
tableName, 1);
+
+ // Compute table statistics to generate a .stats file
+ actions().computeTableStats(sourceTable).execute();
+
+ assertThat(sourceTable.statisticsFiles())
+ .hasSize(1)
+ .as("Should include 1 statistics file after compute stats");
+
+ String targetTableLocation = targetTableLocation();
+ RewriteTablePath.Result result =
+ actions()
+ .rewriteTablePath(sourceTable)
+ .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
+ .execute();
+
+ checkFileNum(3, 1, 1, 1, 7, result);
+
+ // Read the file list to verify statistics file paths
+ List<Tuple2<String, String>> filesToMove =
readPathPairList(result.fileListLocation());
+
+ // Find the statistics file entry in the file list
+ Tuple2<String, String> statsFilePathPair = null;
+ for (Tuple2<String, String> pathPair : filesToMove) {
+ if (pathPair._1().endsWith(".stats")) {
+ statsFilePathPair = pathPair;
+ break;
+ }
+ }
+
+ assertThat(statsFilePathPair).isNotNull().as("Should find statistics file
in file list");
+
+ // Verify the source path points to the actual source location, not staging
+ assertThat(statsFilePathPair._1())
+ .startsWith(sourceTableLocation)
+ .as("Statistics file source should point to source table location");
Review Comment:
Thanks for catching this. I update the tests.
##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteTablePathsAction.java:
##########
@@ -963,6 +963,59 @@ public void testTableWithManyStatisticFiles() throws
IOException {
iterations * 2 + 1, iterations, iterations, iterations, iterations * 6
+ 1, result);
}
+ @Test
+ public void testStatisticsFileSourcePath() throws IOException {
+ String sourceTableLocation = newTableLocation();
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put("format-version", "2");
+ String tableName = "v2tblwithstats";
+ Table sourceTable =
+ createMetastoreTable(sourceTableLocation, properties, "default",
tableName, 1);
+
+ // Compute table statistics to generate a .stats file
+ actions().computeTableStats(sourceTable).execute();
+
+ assertThat(sourceTable.statisticsFiles())
+ .hasSize(1)
+ .as("Should include 1 statistics file after compute stats");
+
+ String targetTableLocation = targetTableLocation();
+ RewriteTablePath.Result result =
+ actions()
+ .rewriteTablePath(sourceTable)
+ .rewriteLocationPrefix(sourceTableLocation, targetTableLocation)
+ .execute();
+
+ checkFileNum(3, 1, 1, 1, 7, result);
+
+ // Read the file list to verify statistics file paths
+ List<Tuple2<String, String>> filesToMove =
readPathPairList(result.fileListLocation());
+
+ // Find the statistics file entry in the file list
+ Tuple2<String, String> statsFilePathPair = null;
+ for (Tuple2<String, String> pathPair : filesToMove) {
+ if (pathPair._1().endsWith(".stats")) {
+ statsFilePathPair = pathPair;
+ break;
+ }
+ }
+
+ assertThat(statsFilePathPair).isNotNull().as("Should find statistics file
in file list");
+
+ // Verify the source path points to the actual source location, not staging
+ assertThat(statsFilePathPair._1())
+ .startsWith(sourceTableLocation)
+ .as("Statistics file source should point to source table location");
Review Comment:
Thanks for catching this. I updated the tests.
--
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]