Hello, I am trying to parse hive queries so that I can get the table names on which the query is dependent on.
I have tried the following : 1) downloaded the grammer and used ANTLR to generate the lexer and parser, but there are some errors as such when I try to build it: ...... symbol: class RecognitionException location: class HiveLexer HiveLexer.java:2432: error: cannot find symbol public final void mKW_ESCAPED() throws RecognitionException { ^ symbol: class RecognitionException location: class HiveLexer HiveLexer.java:2453: error: cannot find symbol public final void mKW_COLLECTION() throws RecognitionException { ^ symbol: class RecognitionException location: class HiveLexer 100 errors 2) I have tried using org.apache.hadoop.hive.ql.parse but I am stuck at this point: ANTLRStringStream input = new ANTLRStringStream("SELECT x FROM abc"); HiveLexer lexer = new HiveLexer(input); TokenStream tokens = new CommonTokenStream(lexer); HiveParser parser = new HiveParser(tokens); System.out.println(parser.statement()); *How should I proceed from here to extract the table names and column names?* *And, Is the way I am doing it correct?* Thank You. Regards, Ritesh