apache-calcite

Apache Calcite - Parse a query with @@ variables


Not sure where else to go so thought I would ask the group.

I have Apache Calcite working as a SQL parser for my application - I am trying to parse MySQL. However it is unable to handle certain SQL statements. The issue seems to be with any SQL statement that contains a variable denoted by "@@" so something like :

SELECT @@session.auto_increment_increment AS auto_increment_increment

fails in the parser. I appreciate this is MySQL specific but was wondering if there is a way to "handle" these @@'s to at least get them into the Node tree so I can provide a more useful response than throw an exception.


Solution

  • There is an open request for this feature, CALCITE-5066. Probably the best way to "handle" these @@ variables is to implement the feature.

    I'm not being facetious. A quick 'hack' solution will likely trip up if @@ characters appear in comments or character literals. So it's better to handle this by modifying the parser. And once you've modified the parser, if you want it to stay working you should write tests and contribute it back to the project.