Search in sources :

Example 1 with HiveASTHintParser

use of org.apache.flink.table.planner.delegation.hive.parse.HiveASTHintParser in project flink by apache.

the class HiveASTParseDriver method parseHint.

/*
     * Parse a string as a query hint.
     */
public HiveParserASTNode parseHint(String command) throws HiveASTParseException {
    LOG.info("Parsing hint: " + command);
    HiveLexerX lexer = new HiveLexerX(new ANTLRNoCaseStringStream(command));
    TokenRewriteStream tokens = new TokenRewriteStream(lexer);
    HiveASTHintParser parser = new HiveASTHintParser(tokens);
    parser.setTreeAdaptor(ADAPTOR);
    HiveASTHintParser.hint_return r = null;
    try {
        r = parser.hint();
    } catch (RecognitionException e) {
        throw new HiveASTParseException(parser.errors);
    }
    if (lexer.getErrors().size() == 0 && parser.errors.size() == 0) {
        LOG.info("Parse Completed");
    } else if (lexer.getErrors().size() != 0) {
        throw new HiveASTParseException(lexer.getErrors());
    } else {
        throw new HiveASTParseException(parser.errors);
    }
    return r.getTree();
}
Also used : TokenRewriteStream(org.antlr.runtime.TokenRewriteStream) HiveASTHintParser(org.apache.flink.table.planner.delegation.hive.parse.HiveASTHintParser) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)1 TokenRewriteStream (org.antlr.runtime.TokenRewriteStream)1 HiveASTHintParser (org.apache.flink.table.planner.delegation.hive.parse.HiveASTHintParser)1