deniskuzZ commented on code in PR #4431:
URL: https://github.com/apache/hive/pull/4431#discussion_r1238466987


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -457,17 +462,20 @@ public List<ColumnStatisticsObj> 
getColStatistics(org.apache.hadoop.hive.ql.meta
     Table table = IcebergTableUtil.getTable(conf, hmsTable.getTTable());
     String statsPath = getStatsPath(table).toString();
     LOG.info("Using stats from puffin file at: {}", statsPath);
+    return readColStats(table, statsPath).equals(null) ? null : 
readColStats(table, statsPath).getStatsObj();
+  }
+
+  private ColumnStatistics readColStats(Table table, String statsPath) {
     try (PuffinReader reader = 
Puffin.read(table.io().newInputFile(statsPath)).build()) {
       List<BlobMetadata> blobMetadata = reader.fileMetadata().blobs();
-      Map<BlobMetadata, List<ColumnStatistics>> collect =
-          
Streams.stream(reader.readAll(blobMetadata)).collect(Collectors.toMap(Pair::first,
-              blobMetadataByteBufferPair -> SerializationUtils.deserialize(
-                  
ByteBuffers.toByteArray(blobMetadataByteBufferPair.second()))));
-      return collect.get(blobMetadata.get(0)).get(0).getStatsObj();
+      Map<BlobMetadata, List<ColumnStatistics>> collect = 
Streams.stream(reader.readAll(blobMetadata)).collect(
+          Collectors.toMap(Pair::first, blobMetadataByteBufferPair -> 
SerializationUtils.deserialize(
+              ByteBuffers.toByteArray(blobMetadataByteBufferPair.second()))));
+      return collect.get(blobMetadata.get(0)).get(0);
     } catch (IOException e) {
       LOG.error("Error when trying to read iceberg col stats from puffin 
files: ", e);
+      return null;

Review Comment:
   should we return an empty?
   ````
   ColumnStatistics empty = new ColumnStatistics();
   csNew.setStatsObj(Lists.newArrayList());
   ````



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to