hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ritesh Gautam <grites...@gmail.com>
Subject Parsing Hive queries to get table names and column names
Date Wed, 05 Nov 2014 13:01:50 GMT
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?*

Is this the correct forum to ask such questions?

Thank You.
Regards,
Ritesh

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message