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();
}
Aggregations