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

NullPointerException when trying to execute prepared statement using avatica

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • avatica-1.7.1
    • avatica-1.8.0
    • avatica
    • None
    • Phoenix 4.7.0 and Phoenix 4.8.0-SNAPSHOT

    Description

      To reproduce, set the phoenix query server to use JSON for serialization:

      1. Create a table called my_table and seed it using SquirrelSQL:

      CREATE TABLE my_table (k BIGINT PRIMARY KEY, v VARCHAR) TRANSACTIONAL=true
      
      UPSERT INTO my_table VALUES (1,'A')
      
      UPSERT INTO my_table VALUES (2,'B')
      
      UPSERT INTO my_table VALUES (3,'C')
      
      UPSERT INTO my_table VALUES (4,'D')
      

      Send the following requests using curl:

      C:\Users\user
      λ curl localhost:8765 -XPOST --data '{"request": "openConnection","connectionId": "my-conn"}'
      
      {"response":"openConnection","rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}}
      
      C:\Users\user
      λ curl localhost:8765 -XPOST --data '{"request": "prepare","connectionId": "my-conn","sql": "SELECT * FROM my_table","maxRowCount": 1}'
      
      {"response":"prepare","statement":{"connectionId":"my-conn","id":36,"signature":{"columns":[{"ordinal":0,"autoIncrement":false,"caseSensitive":false,"searchable":true,"currency":false,"nullable":0,"signed":true,"displaySize":40,"label":"K","columnName":"K","schemaName":"","precision":0,"scale":0,"tableName":"MY_TABLE","catalogName":"","type":{"type":"scalar","id":-5,"name":"BIGINT","rep":"PRIMITIVE_LONG"},"readOnly":true,"writable":false,"definitelyWritable":false,"columnClassName":"java.lang.Long"},{"ordinal":1,"autoIncrement":false,"caseSensitive":false,"searchable":true,"currency":false,"nullable":1,"signed":false,"displaySize":40,"label":"V","columnName":"V","schemaName":"","precision":0,"scale":0,"tableName":"MY_TABLE","catalogName":"","type":{"type":"scalar","id":12,"name":"VARCHAR","rep":"STRING"},"readOnly":true,"writable":false,"definitelyWritable":false,"columnClassName":"java.lang.String"}],"sql":"SELECT * FROM my_table","parameters":[],"cursorFactory":{"style":"LIST","clazz":null,"fieldNames":null},"statementType":null}},"rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}}
      
      C:\Users\user
      λ curl localhost:8765 -XPOST --data '{"request": "execute","statementHandle": {"connectionId": "my-conn","id": 36},"maxRowCount": 1}'
      
      {"response":"error","exceptions":["java.lang.NullPointerException\n\tat org.apache.calcite.avatica.MetaImpl.checkParameterValueHasNull(MetaImpl.java:952)\n\tat org.apache.calcite.avatica.jdbc.JdbcMeta.execute(JdbcMeta.java:781)\n\tat org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:233)\n\tat org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:950)\n\tat org.apache.calcite.avatica.remote.Service$ExecuteRequest.accept(Service.java:928)\n\tat org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:102)\n\tat org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:43)\n\tat org.apache.calcite.avatica.server.AvaticaJsonHandler.handle(AvaticaJsonHandler.java:73)\n\tat org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:245)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)\n\tat java.lang.Thread.run(Thread.java:745)\n"],"errorMessage":"NullPointerException: (null exception message)","errorCode":-1,"sqlState":"00000","severity":"UNKNOWN","rpcMetadata":{"response":"rpcMetadata","serverAddress":"f826338-phoenix-server.f826338:8765"}}
      

      Notice that the server throws a NPE when trying to execute the prepared statement.

      Attachments

        Activity

          People

            elserj Josh Elser
            francischuang Francis Chuang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: