Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Data Tools Project - SQL Query Parser

Just recently discovered the SQL Query Parser classes in the DTP project, and it looks like a great (and unique) project.

My problem is that I need to analyze and see if I can merge some pretty hairy SQL fragments that are used in a big system. I need a smart and capable parser so I can perform an accurate analysis and determine if I can join some of these fragments together to improve performance. I've already figured the analysis I need to perform; however, the parser as-is is not able to parse these fragments, because they use specific db2 OLAP functions (over(), partition by, etc.) so I need to include the db2 plugins to my code.

How is this done? I haven't been able to find the classes (org.eclipse.datatools.sqltools.parsers.sql.query.db2.*) anywhere, and I also have no idea how to register them (I'm trying to do it manually, but of course it cannot find the appropriate class.)

This is what I'm currently doing, which I know is wrong, but I haven't found documentation about it:

SQLQueryParserManagerProvider provider = SQLQueryParserManagerProvider
        .getInstance();

provider.registerParserManager(
        "org.eclipse.datatools.sqltools.parsers.sql.query.db2",
        "DB2 UDB", null, null);

SQLQueryParserManager parserManager = SQLQueryParserManagerProvider
        .getInstance().getParserManager("DB2 UDB", null);

Can you please point out how to get the adequate parser for parsing DB2?

Edit: Probably the right question is, how can I make sure the db2 specific provider is correctly registered? what's the right class name?

like image 502
Leonardo Herrera Avatar asked Apr 04 '13 13:04

Leonardo Herrera


1 Answers

Checkout the project called SQLWorkBench/J sources. They have db-specific SQL parsing capabilities.

like image 146
srini.venigalla Avatar answered Oct 25 '22 00:10

srini.venigalla