private static void genComputeStats(StringBuilder rewrittenQueryBuilder, HiveConf conf,
      int pos, String columnName, TypeInfo typeInfo) throws SemanticException {
    Preconditions.checkArgument(typeInfo.getCategory() == Category.PRIMITIVE);
    ColumnStatsType columnStatsType =
        ColumnStatsType.getColumnStatsType((PrimitiveTypeInfo) typeInfo);
    List<ColumnStatsField> columnStatsFields = columnStatsType.getColumnStats();
    columnStatsFields = ColumnStatsType.removeDisabledStatistics(conf, columnStatsFields);
    // The first column is always the type
    // The rest of columns will depend on the type itself
    for (int i = 0; i < columnStatsFields.size(); i++) {
      ColumnStatsField columnStatsField = columnStatsFields.get(i);
      if (i > 0) {
        rewrittenQueryBuilder.append(", ");
      }
      appendStatsField(rewrittenQueryBuilder, conf, columnStatsField, columnStatsType,
          columnName, pos);
    }
  }
Generates a SQL statement that will compute the stats for all columns
included in the input table.
ql/src/java/org/apache/hadoop/hive/ql/parse/ColumnStatsSemanticAnalyzer.java