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

SQLException not correctly propagated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.5.0
    • None
    • avatica
    • None

    Description

      When using the Phoenix (master) and it raises a SQLException, this is returned from the Avatica RPC server:

      {
        "response":"error",
        "exceptions":[
          "java.lang.RuntimeException: ERROR 202 (22012): Divide by zero.\n"
          "\tat org.apache.calcite.avatica.jdbc.JdbcMeta.propagate(JdbcMeta.java:651)\n"
          "\tat org.apache.calcite.avatica.jdbc.JdbcMeta.prepareAndExecute(JdbcMeta.java:715)\n"
          "\tat org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:179)\n"
          "\tat org.apache.calcite.avatica.remote.Service$PrepareAndExecuteRequest.accept(Service.java:1049)\n"
          "\tat org.apache.calcite.avatica.remote.Service$PrepareAndExecuteRequest.accept(Service.java:1023)\n"
          "\tat org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:100)\n"
          "\tat org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:43)\n"
          "\tat org.apache.calcite.avatica.server.AvaticaHandler.handle(AvaticaHandler.java:68)\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":"ERROR 202 (22012): Divide by zero.",
        "errorCode":-1,
        "sqlState":"00000",
        "severity":"UNKNOWN"
      }
      

      The SQLException is translated to RuntimeException and the errorCode and sqlState fields are set to "unknown" values, even though the codes were originally set in the SQLException.

      I'd expect that https://github.com/apache/calcite/blob/calcite-1.5.0/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java#L645 would have a special case for SQLException and translate it to AvaticaRuntimeException. I'm not sure if that is the correct solution.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lukaslalinsky Lukas Lalinsky
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: