huaxingao commented on code in PR #10659: URL: https://github.com/apache/iceberg/pull/10659#discussion_r1683657327
########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java: ########## @@ -175,7 +184,37 @@ public Statistics estimateStatistics() { protected Statistics estimateStatistics(Snapshot snapshot) { // its a fresh table, no data if (snapshot == null) { - return new Stats(0L, 0L); + return new Stats(0L, 0L, Collections.emptyMap()); + } + + boolean cboEnabled = + Boolean.parseBoolean(spark.conf().get(SQLConf.CBO_ENABLED().key(), "false")); + Map<NamedReference, ColumnStatistics> colStatsMap = null; + if (readConf.enableColumnStats() && cboEnabled) { + colStatsMap = Maps.newHashMap(); + List<StatisticsFile> files = table.statisticsFiles(); + if (!files.isEmpty()) { + List<BlobMetadata> metadataList = (files.get(0)).blobMetadata(); + + for (BlobMetadata blobMetadata : metadataList) { + int id = blobMetadata.fields().get(0); Review Comment: I can't find detailed documentation for `BlobMetadata` in the spec. My understanding is that for the blob type `apache-datasketches-theta-v1`, `ndv` is required. I assume that `ndv` is set in the `properties` as shown in the following example. If my assumption is correct, it seems to me that we can only have one field in the `fields`, establishing a one-to-one relationship with the `ndv` in the properties. ``` new GenericBlobMetadata( APACHE_DATASKETCHES_THETA_V1, snapshotId, 1, ImmutableList.of(1), ImmutableMap.of("ndv", "4")) ``` -- 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