impala

How to access the Impala Parser


Does Impala reuse hive SQL parser?

I am trying to write a custom Java code to check for query correctness in my application. I am searching for an api which can consume the sql query and let me know if it is grammatically correct for impala.

How can I access the parser from a custom Java code to check for query compatibility?


Solution

  • No, Impala does not reuse the Hive parser. Further, Impala does not expose a Java API for checking if a query is grammatically correct. The easiest thing to do is probably to submit an explain query via JDBC and check the result.

    If you don't have a running Impala cluster, in theory you should be able to instantiate the scanner and parser as Impala does in the parser unit tests, but I can imagine it might be difficult to get that working as the Impala build/test environment is quite complicated. Note that this is not a supported API.