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


##########
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:
   HI @huaxingao I have added the logs, kindly give it a check and let me know 
if it works.



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