simhadri-g commented on code in PR #4431:
URL: https://github.com/apache/hive/pull/4431#discussion_r1267233529
##########
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);
Review Comment:
.get(<index>) will through IndexOutofBounds exception. This exception is
caught and If the file is corrupted or empty we will return empty ColumnStats
Object,
--
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]