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


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/source/SparkScan.java:
##########
@@ -198,27 +198,31 @@ protected Statistics estimateStatistics(Snapshot 
snapshot) {
       if (!files.isEmpty()) {
         List<BlobMetadata> metadataList = (files.get(0)).blobMetadata();
 
-        for (BlobMetadata blobMetadata : metadataList) {
-          int id = blobMetadata.fields().get(0);
-          String colName = table.schema().findColumnName(id);
+        Map<Integer, List<BlobMetadata>> groupedByField =
+            metadataList.stream()
+                .collect(
+                    Collectors.groupingBy(
+                        metadata -> metadata.fields().get(0), 
Collectors.toList()));
+
+        for (Map.Entry<Integer, List<BlobMetadata>> entry : 
groupedByField.entrySet()) {
+          String colName = table.schema().findColumnName(entry.getKey());
           NamedReference ref = FieldReference.column(colName);
-
           Long ndv = null;
-          if (blobMetadata
-              .type()
-              
.equals(org.apache.iceberg.puffin.StandardBlobTypes.APACHE_DATASKETCHES_THETA_V1))
 {
-            String ndvStr = blobMetadata.properties().get(NDV_KEY);
-            if (!Strings.isNullOrEmpty(ndvStr)) {
-              ndv = Long.parseLong(ndvStr);
-            } else {
-              LOG.debug("ndv is not set in BlobMetadata for column {}", 
colName);
+
+          for (BlobMetadata blobMetadata : entry.getValue()) {
+            if (blobMetadata
+                .type()
+                
.equals(org.apache.iceberg.puffin.StandardBlobTypes.APACHE_DATASKETCHES_THETA_V1))
 {
+              String ndvStr = blobMetadata.properties().get(NDV_KEY);
+              if (!Strings.isNullOrEmpty(ndvStr)) {
+                ndv = Long.parseLong(ndvStr);
+              } else {
+                LOG.debug("ndv is not set in BlobMetadata for column {}", 
colName);
+              }

Review Comment:
   If the blob type is not `APACHE_DATASKETCHES_THETA_V1`, shall we add a log 
message, something like "Blob type XXX is not supported yet"?



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