private List<String> getAnyStatsToUpdate(String db, String tbl, List<String> allCols,
      Map<String, String> params, long statsWriteId, String writeIdString) throws MetaException {
    // Note: we only run "for columns" command and assume no basic stats means no col stats.
    if (!StatsSetupConst.areBasicStatsUptoDate(params)) {
      return allCols;
    }
    // TODO: we should probably skip updating if writeId is from an active txn
    if (writeIdString != null && !ObjectStore.isCurrentStatsValidForTheQuery(
        params, statsWriteId, writeIdString, false)) {
      return allCols;
    }
    List<String> colsToUpdate = new ArrayList<>();
    for (String col : allCols) {
      if (!StatsSetupConst.areColumnStatsUptoDate(params, col)) {
        colsToUpdate.add(col);
      }
    }
    return colsToUpdate;
  }
Whether to only update stats that already exist and are out of date.
ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUpdaterThread.java