public ParseResult parseSelect(String command, Configuration configuration) throws ParseException {
    LOG.debug("Parsing command: {}", command);

    GenericHiveLexer lexer = GenericHiveLexer.of(command, configuration);
    TokenRewriteStream tokens = new TokenRewriteStream(lexer);
//    if (ctx != null) {
//      ctx.setTokenRewriteStream(tokens);
//    }
    HiveParser parser = new HiveParser(tokens);
    parser.setTreeAdaptor(adaptor);
    parser.setHiveConf(configuration);
    ParserRuleReturnScope r;
    try {
      r = parser.selectClause();
    } catch (RecognitionException e) {
      throw new ParseException(parser.errors, e);
    }

    if (lexer.getErrors().size() == 0 && parser.errors.size() == 0) {
      LOG.debug("Parse Completed");
    } else if (lexer.getErrors().size() != 0) {
      throw new ParseException(lexer.getErrors());
    } else {
      throw new ParseException(parser.errors);
    }

    return new ParseResult((ASTNode) r.getTree(), tokens, parser.gFromClauseParser.tables);
  }
Parses a command, optionally assigning the parser's token stream to the
given context.

@param command
         command to parse

@param configuration
         hive configuration

@return parsed AST
parser/src/java/org/apache/hadoop/hive/ql/parse/ParseDriver.java