You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ralph Gasser (JIRA)" <ji...@apache.org> on 2019/07/03 06:53:00 UTC

[jira] [Commented] (CALCITE-3162) Reading Arrays from Calcite through JdbcMeta generates AvaticaSqlException

    [ https://issues.apache.org/jira/browse/CALCITE-3162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16877532#comment-16877532 ] 

Ralph Gasser commented on CALCITE-3162:
---------------------------------------

I've created a patch that seems to resolve the problem.

> Reading Arrays from Calcite through JdbcMeta generates AvaticaSqlException
> --------------------------------------------------------------------------
>
>                 Key: CALCITE-3162
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3162
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>    Affects Versions: avatica-1.15.0
>         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.
>            Reporter: Ralph Gasser
>            Priority: Major
>         Attachments: patch0002.diff
>
>
> 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.
> {code:java}
> @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();
>     }
>   }
> }
> {code}
> Executing the statement will throw an AvaticaSqlException:
> {code:java}
> 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
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)