private StatType getType(String origType) {
      if (serdeConstants.IntegralTypes.contains(origType)) {
        return StatType.Integer;
      } else if (origType.equals(serdeConstants.DOUBLE_TYPE_NAME) ||
          origType.equals(serdeConstants.FLOAT_TYPE_NAME)) {
        return StatType.Double;
      } else if (origType.equals(serdeConstants.BINARY_TYPE_NAME)) {
        return StatType.Binary;
      } else if (origType.equals(serdeConstants.BOOLEAN_TYPE_NAME)) {
        return StatType.Boolean;
      } else if (origType.equals(serdeConstants.STRING_TYPE_NAME)) {
        return StatType.String;
      } else if (origType.equals(serdeConstants.DATE_TYPE_NAME)) {
        return StatType.Date;
      }
      return StatType.Unsupported;
    }
There is a set of queries which can be answered entirely from statistics stored in metastore.
Examples of such queries are count(*), count(a), max(a), min(b) etc. Hive already collects
these basic statistics for query planning purposes. These same statistics can be used to
answer queries also.

Optimizer looks at query plan to determine if it can answer query using statistics
and than change the plan to answer query entirely using statistics stored in metastore.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java