private int persistColumnStats(Hive db) throws HiveException, MetaException, IOException {
    ColumnStatistics colStats = constructColumnStatsFromInput();
    SetPartitionsStatsRequest request =
            new SetPartitionsStatsRequest(Collections.singletonList(colStats));

    // Set writeId and validWriteId list for replicated statistics. getColStats() will return
    // 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();
      // If it's a transactional table on source and target, we will get a valid writeId
      // 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;
  }
ColumnStatsUpdateTask implementation. For example, ALTER TABLE src_stat
UPDATE STATISTICS for column key SET ('numDVs'='1111','avgColLen'='1.111');
For another example, ALTER TABLE src_stat_part PARTITION(partitionId=100)
UPDATE STATISTICS for column value SET
('maxColLen'='4444','avgColLen'='44.4');
ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnStatsUpdateTask.java