use of org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest in project hive by apache.
the class ColumnStatsUpdateTask method persistColumnStats.
private int persistColumnStats(Hive db) throws HiveException, MetaException, IOException {
ColumnStatistics colStats = constructColumnStatsFromInput();
SetPartitionsStatsRequest request = new SetPartitionsStatsRequest(Collections.singletonList(colStats), Constants.HIVE_ENGINE);
// non-null value only during replication.
if (work.getColStats() != null) {
String dbName = colStats.getStatsDesc().getDbName();
String tblName = colStats.getStatsDesc().getTableName();
Table tbl = db.getTable(dbName, tblName);
long writeId = work.getWriteId();
// associated with it.
if (AcidUtils.isTransactionalTable(tbl)) {
ValidWriteIdList writeIds;
// We need a valid writeId list to update column statistics for a transactional table. We
// do not have a valid writeId list which was used to update the column stats on the
// source. But we know for sure that the writeId associated with the stats was valid then
// (otherwise column stats update would have failed on the source). So use a valid
// transaction list with only that writeId and use it to update the stats.
writeIds = new ValidReaderWriteIdList(TableName.getDbTable(dbName, tblName), new long[0], new BitSet(), writeId);
request.setValidWriteIdList(writeIds.toString());
request.setWriteId(writeId);
}
}
db.setPartitionColumnStatistics(request);
return 0;
}
Aggregations