ayushtkn commented on code in PR #5261:
URL: https://github.com/apache/hive/pull/5261#discussion_r1615325810
##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java:
##########
@@ -498,30 +500,58 @@ public boolean
canSetColStatistics(org.apache.hadoop.hive.ql.metadata.Table hmsT
@Override
public boolean setColStatistics(org.apache.hadoop.hive.ql.metadata.Table
hmsTable, List<ColumnStatistics> colStats) {
Table tbl = IcebergTableUtil.getTable(conf, hmsTable.getTTable());
- String snapshotId = String.format("%s-STATS-%d", tbl.name(),
tbl.currentSnapshot().snapshotId());
- return writeColStats(colStats.get(0), tbl, snapshotId);
+ return writeColStats(colStats.get(0), tbl);
}
- private boolean writeColStats(ColumnStatistics tableColStats, Table tbl,
String snapshotId) {
+ private boolean writeColStats(ColumnStatistics tableColStats, Table tbl) {
try {
- boolean rewriteStats = removeColStatsIfExists(tbl);
- if (!rewriteStats) {
+ if (!shouldRewriteColStats(tbl)) {
checkAndMergeColStats(tableColStats, tbl);
}
// Currently, we are only serializing table level stats.
byte[] serializeColStats = SerializationUtils.serialize(tableColStats);
- try (PuffinWriter writer =
Puffin.write(tbl.io().newOutputFile(getColStatsPath(tbl).toString()))
+ StatisticsFile statisticsFile;
+ String statsPath = tbl.location() + STATS + UUID.randomUUID();
+
+ try (PuffinWriter puffinWriter =
Puffin.write(tbl.io().newOutputFile(statsPath))
.createdBy(Constants.HIVE_ENGINE).build()) {
- writer.add(new Blob(tbl.name() + "-" + snapshotId,
ImmutableList.of(1), tbl.currentSnapshot().snapshotId(),
- tbl.currentSnapshot().sequenceNumber(),
ByteBuffer.wrap(serializeColStats), PuffinCompressionCodec.NONE,
- ImmutableMap.of()));
- writer.finish();
- return true;
+ long snapshotId = tbl.currentSnapshot().snapshotId();
+ long snapshotSequenceNumber = tbl.currentSnapshot().sequenceNumber();
+ puffinWriter.add(
+ new Blob(
+ ColumnStatisticsObj.class.getSimpleName(),
+ ImmutableList.of(1),
+ snapshotId,
+ snapshotSequenceNumber,
+ ByteBuffer.wrap(serializeColStats),
+ PuffinCompressionCodec.ZSTD,
Review Comment:
It should be defined by the config I believe
"write.parquet.compression-codec" "write.avro.compression-codec" & they are
different I believe & even different for us downstream :-)
--
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]