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

NullPointerException when target in ReflectiveSchema belongs to unnamed (root) package

    Details

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

      Description

      When following this foodmart example, I have created the Foodmart and Hr separately with no java package and passing them to ReflectiveSchema, it threw NPE when executing executeQuery.

      [error] (run-main-0) java.sql.SQLException: Error while executing SQL "select * from "hr"."emps"": null
      java.sql.SQLException: Error while executing SQL "select * from "hr"."emps"": null
              at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
              at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
              at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
              at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
              at Main$.main(Main.scala:39)
              at Main.main(Main.scala)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
      Caused by: java.lang.NullPointerException
              at org.apache.calcite.linq4j.tree.Types.className(Types.java:256)
              at org.apache.calcite.linq4j.tree.ExpressionWriter.append(ExpressionWriter.java:124)
              at org.apache.calcite.linq4j.tree.UnaryExpression.accept(UnaryExpression.java:48)
              at org.apache.calcite.linq4j.tree.ExpressionWriter.requireParentheses(ExpressionWriter.java:69)
              at org.apache.calcite.linq4j.tree.UnaryExpression.accept(UnaryExpression.java:47)
              at org.apache.calcite.linq4j.tree.MemberExpression.accept(MemberExpression.java:71)
              at org.apache.calcite.linq4j.tree.MethodCallExpression.accept(MethodCallExpression.java:105)
              at org.apache.calcite.linq4j.tree.GotoStatement.accept0(GotoStatement.java:84)
              at org.apache.calcite.linq4j.tree.Statement.accept(Statement.java:32)
              at org.apache.calcite.linq4j.tree.BlockStatement.accept0(BlockStatement.java:75)
              at org.apache.calcite.linq4j.tree.ExpressionWriter.append(ExpressionWriter.java:129)
              at org.apache.calcite.linq4j.tree.MethodDeclaration.accept(MethodDeclaration.java:79)
              at org.apache.calcite.linq4j.tree.ExpressionWriter.write(ExpressionWriter.java:49)
              at org.apache.calcite.linq4j.tree.Expressions.toString(Expressions.java:55)
              at org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:93)
              at org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1257)
              at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:331)
              at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:784)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:639)
              at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:609)
              at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:214)
              at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603)
              at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
              at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
              at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
              at Main$.main(Main.scala:39)
              at Main.main(Main.scala)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
      [trace] Stack trace suppressed: run last compile:run for the full output.
      java.lang.RuntimeException: Nonzero exit code: 1
              at scala.sys.package$.error(package.scala:27)
      [trace] Stack trace suppressed: run last compile:run for the full output.
      [error] (compile:run) Nonzero exit code: 1
      [error] Total time: 10 s, completed Aug 2, 2017 11:45:24 AM
      
      

        Activity

        Hide
        michaelmior Michael Mior added a comment -

        Resolved in release 1.14.0 (2017-10-01)

        Show
        michaelmior Michael Mior added a comment - Resolved in release 1.14.0 (2017-10-01)
        Hide
        ch33hau Lim Chee Hau added a comment -

        Thanks, and appreciated for the test case!

        Show
        ch33hau Lim Chee Hau added a comment - Thanks, and appreciated for the test case!
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/3d88b254. Thanks for the PR, Lim Chee Hau! I added a test case.

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/3d88b254 . Thanks for the PR, Lim Chee Hau ! I added a test case.
        Hide
        julianhyde Julian Hyde added a comment -

        Reviewing now.

        Show
        julianhyde Julian Hyde added a comment - Reviewing now.
        Hide
        ch33hau Lim Chee Hau added a comment -
        Show
        ch33hau Lim Chee Hau added a comment - I have created a PR here: https://github.com/apache/calcite/pull/505

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            ch33hau Lim Chee Hau
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development