anuragmantri commented on code in PR #13881: URL: https://github.com/apache/iceberg/pull/13881#discussion_r2291726021
########## 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()) + .as("Should include 1 statistics file after compute stats") + .hasSize(1); + + 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).as("Should find statistics file in file list").isNotNull(); + + // Verify the source path points to the actual source location, not staging + assertThat(statsFilePathPair._1()) + .as("Statistics file source should point to source table location") + .startsWith(sourceTableLocation); + assertThat(statsFilePathPair._1()) + .as("Statistics file source should NOT point to staging directory") + .doesNotContain("staging"); Review Comment: Done ########## 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()) + .as("Should include 1 statistics file after compute stats") + .hasSize(1); + + 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; + } + } Review Comment: Done -- 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