6

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?

3
  • How do you in fact know there is a DB2-compatible parser? A real problem with most language parsers is that they are in fact for a very specific dialect of such langauge, and yet there are many dialects produced by the various suppliers (e.g., SQL2011 [standard], PL/SQL 8/9/10/11, MySQL, TSQL, DB2, all of them different). If somebody hasn't specifically addressed the DB2 dialect ("I can't find classes ....db2.*") then they may simply not exist. Commented Apr 4, 2013 at 14:12
  • Well, it's right there in the documentation, and IBM Data Studio supposedly uses it. Commented Apr 4, 2013 at 14:23
  • Still looking at this - the closest hierarchy to what the documentation shows is org.eclipse.datatools.enablement.ibm.db2 but still no luck Commented Apr 8, 2013 at 19:26

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Looks like a nice project. It shows some features that hint that their parser is quite powerful (their 'src/sql' directory seems promising.) Alas, I don't have db2 drivers in my PC and it requires a profile, and db2 wasn't in the list. I'll keep investigating, thought.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.