private ASTNode assertTrimFunction(
          ASTNode tree, String expectedFunctionName, String expectedStringToTrim, int functionNodeChildCount) {
    assertEquals(1, tree.getChildCount());
    ASTNode selExprNode = (ASTNode) tree.getChild(0);
    assertEquals(1, selExprNode.getChildCount());
    ASTNode functionNode = (ASTNode) selExprNode.getChild(0);
    assertEquals(HiveParser.TOK_FUNCTION, functionNode.getType());
    assertEquals(functionNodeChildCount, functionNode.getChildCount());

    ASTNode functionNameNode = (ASTNode) functionNode.getChild(0);
    assertEquals(HiveParser.Identifier, functionNameNode.getType());
    assertEquals(expectedFunctionName, functionNameNode.getText());

    ASTNode strToTrimNode = (ASTNode) functionNode.getChild(1);
    assertEquals(HiveParser.StringLiteral, strToTrimNode.getType());
    assertEquals(expectedStringToTrim, strToTrimNode.getText());

    return functionNode;
  }
Test cases for parse WITHIN GROUP clause syntax.
function(expression) WITHIN GROUP (ORDER BY sort_expression)
parser/src/test/org/apache/hadoop/hive/ql/parse/TestParseTrim.java