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

Reading Arrays from Calcite through JdbcMeta generates AvaticaSqlException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: avatica-1.15.0
    • Fix Version/s: avatica-1.19.0
    • Component/s: avatica
    • Environment:

      Tested on OS X 10.14.5, OpenJDK Runtime Environment Zulu11.29+3-CA (build 11.0.2+7-LTS)

      Issue occurs with both Apache Calcite 1.19.0 & 1.20.0.

      Description

      I'm trying to use Apache Calcite as SQL Parser and Query Planner for a custom data store and in addition, I'm using Apache Avatica to expose the entire functionality via JDBC for an arbitrary, potential remote client to use. 

      We're working a lot with Array types, since we're using our backend to store high-dimensional vectors. However, it seems that currently, Apache Avatica has troubles handling such arrays.

      Take the following test-case that reproduces the problem pretty well.

      @Test
      public void test() throws Exception {
      
        HttpServer server = null;
        try {
          Class.forName("org.apache.calcite.jdbc.Driver");
          server = new HttpServer.Builder<>()
                   .withHandler(new LocalService(new JdbcMeta("jdbc:calcite:", newProperties())),Driver.Serialization.PROTOBUF)
                   .withPort(1234)
                   .build();
      
          server.start();
      
          final Connection connection = DriverManager.getConnection("jdbc:avatica:remote:serialization=protobuf;url=http://127.0.0.1:1234");
          final Statement stmt = connection.createStatement();
          final ResultSet resultSet = stmt.executeQuery("select ARRAY[1.0, 1.0, 3.0, 2.0]");
          resultSet.next();
          resultSet.getArray(1);
        } catch (Exception e) {
          System.out.println(e.getMessage());
        } finally {
          if (server != null) {
             server.stop();
          }
        }
      }
      

      Executing the statement will throw an AvaticaSqlException:

      org.apache.calcite.avatica.AvaticaSqlException: Error -1 (00000) : Error while executing SQL "select ARRAY[1.0, 1.0, 3.0, 2.0]": Remote driver error: RuntimeException: java.sql.SQLException: invalid column ordinal: 2 -> SQLException: invalid column ordinal: 2
      

      The culprit seems to be the org.apache.calcite.avatica.jdbc.JdbcResultSet class. More specifically, the JdbcResultSet#extractUsingResultSet() method.

      I am actually testing a potential fix but first I wanted to make sure, that there is nothing wrong with the way I'm using the two components.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ppanopticon Ralph Gasser
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m