You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Miles Spielberg (JIRA)" <ji...@apache.org> on 2018/07/19 01:50:00 UTC

[jira] [Comment Edited] (CALCITE-2362) PreparedStatement.setObject does not handle Array

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

Miles Spielberg edited comment on CALCITE-2362 at 7/19/18 1:49 AM:
-------------------------------------------------------------------

Exception from running the attached code:
{code}
java.lang.RuntimeException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:653)
        at org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:513)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1081)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1002)
        at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeRequest(ProtobufTranslationImpl.java:314)
        at org.apache.calcite.avatica.remote.RemoteProtobufService._apply(RemoteProtobufService.java:45)
        at org.apache.calcite.avatica.remote.ProtobufService.apply(ProtobufService.java:97)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:344)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:342)
        at org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:756)
        at org.apache.calcite.avatica.remote.RemoteMeta.execute(RemoteMeta.java:341)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:511)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeUpdate(AvaticaPreparedStatement.java:146)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeUpdate(AvaticaPreparedStatement.java:142)
        at Main.main(Main.java:12)
Exception in thread "main" java.sql.SQLException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
        at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:520)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeUpdate(AvaticaPreparedStatement.java:146)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeUpdate(AvaticaPreparedStatement.java:142)
        at Main.main(Main.java:12)
Caused by: java.lang.RuntimeException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:653)
        at org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:513)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1081)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1002)
        at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeRequest(ProtobufTranslationImpl.java:314)
        at org.apache.calcite.avatica.remote.RemoteProtobufService._apply(RemoteProtobufService.java:45)
        at org.apache.calcite.avatica.remote.ProtobufService.apply(ProtobufService.java:97)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:344)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:342)
        at org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:756)
        at org.apache.calcite.avatica.remote.RemoteMeta.execute(RemoteMeta.java:341)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:511)
        ... 3 more
{code}

Replacing the call to setObject() with a call to setArray() resolves the problem. We're using a JDBC framework that always uses setObject(), so this is not an easy option in our application.

Does this help?


was (Author: mspielberg):
Exception from running the attached code:
{code}
java.lang.RuntimeException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:653)
        at org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:513)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1081)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1002)
        at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeRequest(ProtobufTranslationImpl.java:314)
        at org.apache.calcite.avatica.remote.RemoteProtobufService._apply(RemoteProtobufService.java:45)
        at org.apache.calcite.avatica.remote.ProtobufService.apply(ProtobufService.java:97)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:344)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:342)
        at org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:756)
        at org.apache.calcite.avatica.remote.RemoteMeta.execute(RemoteMeta.java:341)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:511)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeUpdate(AvaticaPreparedStatement.java:146)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeUpdate(AvaticaPreparedStatement.java:142)
        at Main.main(Main.java:12)
Exception in thread "main" java.sql.SQLException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
        at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:520)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeUpdate(AvaticaPreparedStatement.java:146)
        at org.apache.calcite.avatica.AvaticaPreparedStatement.executeUpdate(AvaticaPreparedStatement.java:142)
        at Main.main(Main.java:12)
Caused by: java.lang.RuntimeException: Unhandled value: OBJECT class org.apache.calcite.avatica.util.ArrayImpl
        at org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:653)
        at org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:513)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1081)
        at org.apache.calcite.avatica.remote.Service$ExecuteRequest.serialize(Service.java:1002)
        at org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeRequest(ProtobufTranslationImpl.java:314)
        at org.apache.calcite.avatica.remote.RemoteProtobufService._apply(RemoteProtobufService.java:45)
        at org.apache.calcite.avatica.remote.ProtobufService.apply(ProtobufService.java:97)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:344)
        at org.apache.calcite.avatica.remote.RemoteMeta$15.call(RemoteMeta.java:342)
        at org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:756)
        at org.apache.calcite.avatica.remote.RemoteMeta.execute(RemoteMeta.java:341)
        at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:511)
        ... 3 more
{code}

Does this help?

> PreparedStatement.setObject does not handle Array
> -------------------------------------------------
>
>                 Key: CALCITE-2362
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2362
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>            Reporter: Miles Spielberg
>            Assignee: Julian Hyde
>            Priority: Major
>         Attachments: Main.java, build.gradle
>
>
> Currently setObject() infers the type of the parameter by calling TypedValue.ofJdbc, which delegates to Rep.of(value.getClass()) to do a lookup in VALUE_MAP. VALUE_MAP containsĀ an entry for java.sql.Array, but this is an interface type, which can never match the actual class of avatica.util.ArrayImpl.
> Instead the implementation falls back to OBJECT, which then fails during serialization.



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