huaxingao commented on code in PR #11040:
URL: https://github.com/apache/iceberg/pull/11040#discussion_r1739562317


##########
spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkScan.java:
##########
@@ -318,46 +322,44 @@ public void testMultipleSnapshotsWithColStats() throws 
NoSuchTableException {
         .append();
     table.refresh();
     long snapshotId2 = table.currentSnapshot().snapshotId();
+    SparkActions.get().computeTableStats(table).execute();
 
-    SparkScanBuilder scanBuilder =
-        new SparkScanBuilder(spark, table, CaseInsensitiveStringMap.empty());
-    SparkScan scan = (SparkScan) scanBuilder.build();
+    spark
+        .createDataset(List.of(new SimpleRecord(6, "a")), 
Encoders.bean(SimpleRecord.class))
+        .coalesce(1)
+        .writeTo(tableName)
+        .append();
+    table.refresh();
+    // No stats generated for this snapshot
+    long snapshotId3 = table.currentSnapshot().snapshotId();
+
+    SparkScan scan1 = buildScanForSnapshot(snapshotId1);
+    SparkScan scan2 = buildScanForSnapshot(snapshotId2);
+    SparkScan scan3 = buildScanForSnapshot(snapshotId3);
 
     Map<String, String> reportColStatsEnabled =
         ImmutableMap.of(SQLConf.CBO_ENABLED().key(), "true");
+    withSQLConf(
+        reportColStatsEnabled,
+        () -> {
+          checkColStatisticsReported(scan1, 4, Map.of("id", 4L));
+          checkColStatisticsReported(scan2, 5, Map.of("id", 5L));
 
-    GenericStatisticsFile statisticsFile =
-        new GenericStatisticsFile(
-            snapshotId1,
-            "/test/statistics/file1.puffin",
-            100,
-            42,
-            ImmutableList.of(
-                new GenericBlobMetadata(
-                    APACHE_DATASKETCHES_THETA_V1,
-                    snapshotId1,
-                    1,
-                    ImmutableList.of(1),
-                    ImmutableMap.of("ndv", "4"))));
-    table.updateStatistics().setStatistics(snapshotId1, 
statisticsFile).commit();
+          Statistics statistics = scan3.estimateStatistics();
+          assertThat(statistics.columnStats()).isEmpty();

Review Comment:
   use `checkColStatisticsNotReported(scan3, 6)`?



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

Reply via email to