Details
Description
I tried to ask calcite-core to parse the following SQL query:
final SqlParser.Config parserConfig = SqlParser.configBuilder() .setConformance(SqlConformanceEnum.MYSQL_5) .setLex(Lex.MYSQL) .build(); String query = "SELECT * FROM departments d INNER JOIN (dept_manager m INNER JOIN employees e ON m.emp_no = e.emp_no) ON d.dept_no = m.dept_no"; SqlParser.create(query, parserConfig).parseQuery();
But there is the following exception:
Exception in thread "main" org.apache.calcite.sql.parser.SqlParseException: Non-query expression encountered in illegal contextException in thread "main" org.apache.calcite.sql.parser.SqlParseException: Non-query expression encountered in illegal context at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:362) at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:147) at org.apache.calcite.sql.parser.SqlParser.handleException(SqlParser.java:148) at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:163) at org.apache.calcite.Runner.main(Runner.java:60)Caused by: org.apache.calcite.runtime.CalciteException: Non-query expression encountered in illegal context at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:572) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:835) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:820) at org.apache.calcite.sql.parser.impl.SqlParserImpl.checkNonQueryExpression(SqlParserImpl.java:306) at org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression3(SqlParserImpl.java:13780) at org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression2b(SqlParserImpl.java:13449) at org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression2(SqlParserImpl.java:13490) at org.apache.calcite.sql.parser.impl.SqlParserImpl.Expression(SqlParserImpl.java:13421) at org.apache.calcite.sql.parser.impl.SqlParserImpl.LeafQueryOrExpr(SqlParserImpl.java:13398) at org.apache.calcite.sql.parser.impl.SqlParserImpl.QueryOrExpr(SqlParserImpl.java:12874) at org.apache.calcite.sql.parser.impl.SqlParserImpl.OrderedQueryOrExpr(SqlParserImpl.java:478) at org.apache.calcite.sql.parser.impl.SqlParserImpl.ParenthesizedExpression(SqlParserImpl.java:639) at org.apache.calcite.sql.parser.impl.SqlParserImpl.TableRef2(SqlParserImpl.java:8145) at org.apache.calcite.sql.parser.impl.SqlParserImpl.TableRef(SqlParserImpl.java:8068) at org.apache.calcite.sql.parser.impl.SqlParserImpl.FromClause(SqlParserImpl.java:7969) at org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlSelect(SqlParserImpl.java:3722) at org.apache.calcite.sql.parser.impl.SqlParserImpl.LeafQuery(SqlParserImpl.java:604) at org.apache.calcite.sql.parser.impl.SqlParserImpl.LeafQueryOrExpr(SqlParserImpl.java:13404) at org.apache.calcite.sql.parser.impl.SqlParserImpl.QueryOrExpr(SqlParserImpl.java:12874) at org.apache.calcite.sql.parser.impl.SqlParserImpl.OrderedQueryOrExpr(SqlParserImpl.java:478) at org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlStmt(SqlParserImpl.java:3626) at org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlStmtEof(SqlParserImpl.java:3664) at org.apache.calcite.sql.parser.impl.SqlParserImpl.parseSqlStmtEof(SqlParserImpl.java:194) at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:161) ... 1 more Process finished with exit code 1
I have tried to run the above query in MySQL database and I am sure it is valid syntax. Can anyone help to explain why the above exception is thrown? Thanks. And how should I fix this?
Attachments
Issue Links
- duplicates
-
CALCITE-35 Support parenthesized sub-clause in JOIN
- Closed