Calcite parsing error on column contains keywords
- Dominant language
- Java
- Stars
- 6.1k
- Forks
- 1.5k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 189
Description
E.g. Running OfflineComplexTypeHandlingQuickStart
Then execute query:
```
SELECT payload.commits.distinct FROM githubEvents LIMIT 1
```
This can be fixed by using double quote, but still very annoying when generating this kind of queries from presto.
Ref Stacktrace:
```
2022/01/27 13:08:14.166 ERROR [PinotQueryResource] [grizzly-http-server-25] Caught exception while compiling SQL query: SELECT payload.commits.distinct FROM githubEvents LIMIT 1
org.apache.pinot.sql.parsers.SqlCompilationException: Caught exception while parsing query: SELECT payload.commits.distinct FROM githubEvents LIMIT 1
at org.apache.pinot.sql.parsers.CalciteSqlParser.compileCalciteSqlToPinotQuery(CalciteSqlParser.java:330) ~[classes/:?]
at org.apache.pinot.sql.parsers.CalciteSqlParser.compileToPinotQuery(CalciteSqlParser.java:134) ~[classes/:?]
at org.apache.pinot.sql.parsers.CalciteSqlCompiler.compileToBrokerRequest(CalciteSqlCompiler.java:35) ~[classes/:?]
at org.apache.pinot.controller.api.resources.PinotQueryResource.getQueryResponse(PinotQueryResource.java:166) ~[classes/:?]
at org.apache.pinot.controller.api.resources.PinotQueryResource.handlePostSql(PinotQueryResource.java:137) ~[classes/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:292) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:274) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.internal.Errors.process(Errors.java:244) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) [jersey-common-2.28.jar:?]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:679) [jersey-server-2.28.jar:?]
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:353) [jersey-container-grizzly2-http-2.28.jar:?]
at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:200) [grizzly-http-server-2.4.4.jar:2.4.4]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) [grizzly-framework-2.4.4.jar:2.4.4]
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) [grizzly-framework-2.4.4.jar:2.4.4]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered ". distinct" at line 1, column 24.
Was expecting one of:
"ORDER" ...
"LIMIT" ...
"OFFSET" ...
"FETCH" ...
"FROM" ...
"," ...
...
...
...
...
...
"UNION" ...
"INTERSECT" ...
"EXCEPT" ...
"MINUS" ...
"." ...
"." ...
"." ...
"." ...
"." ...
"IN" ...
"<" ...
"<=" ...
">" ...
">=" ...
"=" ...
"<>" ...
"!=" ...
"+" ...
"-" ...
"*" ...
"/" ...
"%" ...
"||" ...
"[" ...
"." "*" ...
"(" ...
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.convertException(SqlBabelParserImpl.java:355) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.normalizeException(SqlBabelParserImpl.java:143) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:156) ~[calcite-core-1.19.0.jar:1.19.0]
at org.apache.pinot.sql.parsers.CalciteSqlParser.compileCalciteSqlToPinotQuery(CalciteSqlParser.java:328) ~[classes/:?]
... 30 more
Caused by: org.apache.calcite.sql.parser.babel.ParseException: Encountered ". distinct" at line 1, column 24.
Was expecting one of:
"ORDER" ...
"LIMIT" ...
"OFFSET" ...
"FETCH" ...
"FROM" ...
"," ...
...
...
...
...
...
"UNION" ...
"INTERSECT" ...
"EXCEPT" ...
"MINUS" ...
"." ...
"." ...
"." ...
"." ...
"." ...
"IN" ...
"<" ...
"<=" ...
">" ...
">=" ...
"=" ...
"<>" ...
"!=" ...
"+" ...
"-" ...
"*" ...
"/" ...
"%" ...
"||" ...
"[" ...
"." "*" ...
"(" ...
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.generateParseException(SqlBabelParserImpl.java:31520) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.jj_consume_token(SqlBabelParserImpl.java:31337) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.SqlStmtEof(SqlBabelParserImpl.java:878) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.babel.SqlBabelParserImpl.parseSqlStmtEof(SqlBabelParserImpl.java:199) ~[calcite-babel-1.19.0.jar:1.19.0]
at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:148) ~[calcite-core-1.19.0.jar:1.19.0]
at org.apache.pinot.sql.parsers.CalciteSqlParser.compileCalciteSqlToPinotQuery(CalciteSqlParser.java:328) ~[classes/:?]
... 30 more
```
Contributor guide
Research direction
Reproduce the query after running OfflineComplexTypeHandlingQuickStart, then start at CalciteSqlParser.compileCalciteSqlToPinotQuery in CalciteSqlParser.java and inspect the reported Calcite parsing failure. Done means the unquoted payload.commits.distinct query parses successfully, while quoted identifiers continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100