Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-459

TokenMgrError parsing error when the query terminates a single-line comment without newline

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:

      Description

      Here's the test (based on the bug report in https://github.com/vlsi/mat-calcite-plugin/issues/1):

        /** Tests comment without ending newline */
        @Test public void testCommentWithoutNewLine() {
          OptiqAssert.that()
              .with(OptiqAssert.Config.REGULAR)
              .query(
                  "select \"empid\" from \"hr\".\"emps\"\n-- select")
              .typeIs(
                  "[empid INTEGER NOT NULL]")
              .returnsUnordered(
                  "empid=100",
                  "empid=110",
                  "empid=150",
                  "empid=200");
        }
      
      java.lang.RuntimeException: exception while executing [select "empid" from "hr"."emps"
      -- select]
      	at net.hydromatic.optiq.test.OptiqAssert$AssertQuery.typeIs(OptiqAssert.java:1088)
      	at net.hydromatic.optiq.test.JdbcTest.testCommentWithoutNewLine(JdbcTest.java:3812)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      Caused by: java.lang.RuntimeException: With materializationsEnabled=false, limit=0
      	at net.hydromatic.optiq.test.OptiqAssert.assertQuery(OptiqAssert.java:419)
      	at net.hydromatic.optiq.test.OptiqAssert$AssertQuery.typeIs(OptiqAssert.java:1084)
      	... 27 more
      Caused by: java.sql.SQLException: error while executing SQL "select "empid" from "hr"."emps"
      -- select": parse failed: Lexical error at line 2, column 10.  Encountered: <EOF> after : ""
      	at net.hydromatic.avatica.Helper.createException(Helper.java:39)
      	at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:79)
      	at net.hydromatic.optiq.test.OptiqAssert.assertQuery(OptiqAssert.java:394)
      	... 28 more
      Caused by: java.lang.RuntimeException: parse failed: Lexical error at line 2, column 10.  Encountered: <EOF> after : ""
      	at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:395)
      	at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare_(OptiqPrepareImpl.java:322)
      	at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepareSql(OptiqPrepareImpl.java:291)
      	at net.hydromatic.optiq.jdbc.OptiqConnectionImpl.parseQuery(OptiqConnectionImpl.java:170)
      	at net.hydromatic.optiq.jdbc.MetaImpl.prepare(MetaImpl.java:622)
      	at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:76)
      	... 29 more
      Caused by: org.eigenbase.sql.parser.SqlParseException: Lexical error at line 2, column 10.  Encountered: <EOF> after : ""
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:327)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:68)
      	at org.eigenbase.sql.parser.SqlParser.parseStmt(SqlParser.java:149)
      	at net.hydromatic.optiq.prepare.OptiqPrepareImpl.prepare2_(OptiqPrepareImpl.java:392)
      	... 34 more
      Caused by: org.eigenbase.sql.parser.impl.TokenMgrError: Lexical error at line 2, column 10.  Encountered: <EOF> after : ""
      	at org.eigenbase.sql.parser.impl.SqlParserImplTokenManager.getNextToken(SqlParserImplTokenManager.java:13715)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.jj_scan_token(SqlParserImpl.java:15844)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.jj_3_273(SqlParserImpl.java:15071)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.jj_2_273(SqlParserImpl.java:6888)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.CompoundIdentifier(SqlParserImpl.java:3348)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.TableRef(SqlParserImpl.java:1440)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.FromClause(SqlParserImpl.java:1353)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.SqlSelect(SqlParserImpl.java:752)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.LeafQuery(SqlParserImpl.java:516)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.LeafQueryOrExpr(SqlParserImpl.java:2151)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.QueryOrExpr(SqlParserImpl.java:2070)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.OrderedQueryOrExpr(SqlParserImpl.java:434)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.SqlStmt(SqlParserImpl.java:692)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.SqlStmtEof(SqlParserImpl.java:718)
      	at org.eigenbase.sql.parser.impl.SqlParserImpl.parseSqlStmtEof(SqlParserImpl.java:121)
      	at org.eigenbase.sql.parser.SqlParser.parseStmt(SqlParser.java:142)
      	... 35 more
      
      
      Process finished with exit code 255
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                vladimirsitnikov Vladimir Sitnikov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: