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 09:59:00 UTC
[jira] [Comment Edited] (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 edited comment on CALCITE-3162 at 7/3/19 9:58 AM:
---------------------------------------------------------------
-I've created a patch that seems to resolve the problem.-
The problem is a but more tricky than I had expected. The main issue seems to be, that the ResultSet produced by CalciteResultset#create() does not adhere to the structure expected by the _JdbcResultSet#extractUsingResultSet(),_ which should consist of __ +two columns:+ index -> value.
However, _CalciteResultset_ inherits and overwrites the create() method from _ArrayFactoryImpl_ (transitively through _AvaticaResultset_)_,_ where that structure is outlined. So that structural difference seems to be on purpose.
The easiest solution probably is to catch all exceptions thrown by _JdbcResultSet#extractUsingResultSet()_ (line 227) and then go down the alternative path.
was (Author: ppanopticon):
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
>
> 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)