Failure of SQL query during parsing
Describe the bug
When I use JSQLParser libraries to parse SQL query , it failed as follows when invoking following statement and query.
Passed SQL Query on which failure happen:
"SELECT of.Full_Name_c AS FullName FROM comdb.Offer_c AS of"
val statement: Statement = CCJSqlParserUtil.parse(sqlQuery)
Exception trace:
Caused by:
net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "SELECT" <K_SELECT>
at line 1, column 1.
Was expecting one of:
"CALL"
"COMMENT"
"COMMIT"
"DECLARE"
"DELETE"
"DESCRIBE"
"DROP"
"EXEC"
"EXECUTE"
"EXPLAIN"
"GRANT"
"INSERT"
"MERGE"
"SET"
"SHOW"
"TRUNCATE"
"UPDATE"
"UPSERT"
"USE"
"VALUES"
"WITH"
at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:25031)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:24875)
at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:244)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:81)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:63)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:40)
But same query passed when I changed the alias as follows:
// This query worked by changing alias 'of' to 'off'
"SELECT off.Full_Name_c AS FullName FROM comdb.Offer_c AS off"
// This works as alias 'af' used inplace of 'of' quite strange
"SELECT af.Full_Name_c AS FullName FROM comdb.Offer_c AS af"
This query is created by third party system so it is not in our control to change the alias from 'of' to something that work.
To Reproduce Steps to reproduce the behavior:
-
Example SQL
"SELECT of.Full_Name_c AS FullName FROM comdb.Offer_c AS of" -
Parsing this SQL using JSqlParser with this statements
val statement: Statement = CCJSqlParserUtil.parse(sqlQuery)
3. Exception
Expected behavior Query must work irrespective whether I use alias of or not. Please let us know how to fix it.
System
- Database you are using = MySQL 5.7.25
- Java Version = 8.0+
- JSqlParser version = 3.2
@wumpz Can you please help on this issue.
Took a while. Now I am back on business.
@wumpz Thanks for the fix. I appreciate all your help. What is the planned release for this fix in future.
Hi, At the moment not yet. There are more PRs to merge.Tobias -------- Ursprüngliche Nachricht --------Von: Peeyush Bishnoi [email protected] Datum: 11.08.20 06:39 (GMT+01:00) An: JSQLParser/JSqlParser [email protected] Cc: Tobias [email protected], Mention [email protected] Betreff: Re: [JSQLParser/JSqlParser] Failure of SQL query during parsing (#1029) @wumpz Thanks for the fix. I appreciate all your help. What is the planned release for this fix in future.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.