amogh-jahagirdar commented on code in PR #11040: URL: https://github.com/apache/iceberg/pull/11040#discussion_r1737878864
########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkScan.java: ########## @@ -293,6 +293,73 @@ public void testTableWithTwoColStats() throws NoSuchTableException { withSQLConf(reportColStatsEnabled, () -> checkColStatisticsReported(scan, 4L, expectedTwoNDVs)); } + @TestTemplate + public void testMultipleSnapshotsWithColStats() throws NoSuchTableException { Review Comment: I think we're missing a test for the case where a statistics file for the snapshot couldn't be found? Let me know if I just missed it. ########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java: ########## @@ -242,6 +246,13 @@ protected Statistics estimateStatistics(Snapshot snapshot) { return new Stats(sizeInBytes, rowsCount, colStatsMap); } + private Optional<StatisticsFile> statisticsFile(Snapshot snapshot) { + long snapshotId = snapshot.snapshotId(); + return table.statisticsFiles().stream() + .filter(statisticsFile -> statisticsFile.snapshotId() == snapshotId) + .findFirst(); Review Comment: Nit: I feel like this could just be inlined above instead of having a separate helper method, but not super opinonated. -- 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