protected boolean hasGroupBySibling(ASTNode selectExpr) {
    boolean isGroupBy = false;
    if (selectExpr.getParent() != null && selectExpr.getParent() instanceof Node) {
      for (Node sibling : ((Node)selectExpr.getParent()).getChildren()) {
        isGroupBy |= sibling instanceof ASTNode && ((ASTNode)sibling).getType() == HiveParser.TOK_GROUPBY;
      }
    }

    return isGroupBy;
  }
Returns the GBY, if present;
DISTINCT, if present, will be handled when generating the SELECT.
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java