public static String generateErrorMessage(ASTNode ast, String message) {
    StringBuilder sb = new StringBuilder();
    if (ast == null) {
      sb.append(message).append(". Cannot tell the position of null AST.");
      return sb.toString();
    }
    sb.append(ast.getLine());
    sb.append(":");
    sb.append(ast.getCharPositionInLine());
    sb.append(" ");
    sb.append(message);
    sb.append(". Error encountered near token '");
    sb.append(ASTErrorUtils.getText(ast));
    sb.append("'");
    return sb.toString();
  }
DFS-scan the expressionTree to find all aggregation subtrees and put them
in aggregations.

@param expressionTree
@param aggregations
         the key to the HashTable is the toStringTree() representation of
         the aggregation subtree.
@throws SemanticException
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java