[jira] [Commented] (CALCITE-3506) ClassCastException in TypedValue.writetoProtoWithType when a boxed Float is used

2019-11-15 Thread Enrique Saurez (Jira)


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

Enrique Saurez commented on CALCITE-3506:
-

I agree that my test is not something useful to add to the codebase, I just 
wanted to show an example of how an exception like mine could be triggered. My 
problem is that it is hard for me to create a better test case, because in my 
use case I am only using Avatica, and not the "normal" backend database. And I 
haven't being able to find the exact query in my system that is triggering this 
exception (just because of lack of visibility in my current test environment, I 
will try to invest a little more hours into this, to try to give you something 
more concrete), but I have a feeling that I am treating Floats differently that 
the backend used in your unit test.

After changing the Avatica code from:
{code:java}
writeToProtoWithType(builder, ((Float) o).longValue(), Common.Rep.FLOAT);
{code}
 

to
{code:java}
writeToProtoWithType(builder, (Float) o, Common.Rep.FLOAT); 
{code}
I don't longer have the exception, so it would be useful to know why the cast 
from Float to long is needed. This doesn't mean this is the solution, but I 
just wanted to understand if this was the real issue in my system.

I am also having trouble setting up the Avatica codebase with my IDE (Intellij 
IDEA), so it is hard for me to step-through your unit test and then can check 
the path in my backend. I am still not too familiar with Avatica codebase.

Thanks again for helping :)

> ClassCastException in TypedValue.writetoProtoWithType when a boxed Float is 
> used
> 
>
> Key: CALCITE-3506
> URL: https://issues.apache.org/jira/browse/CALCITE-3506
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: avatica-1.12.0
>Reporter: Enrique Saurez
>Priority: Major
>
>  am using Apache Calcite-Avatica version 1.12 (but the relevant code
>  sections are not different from the master branch), and I am getting
>  the following exception on the client side (but the actual error in on
>  the server side):
> ||Exception||
> |org.apache.calcite.avatica.AvaticaSqlException: Error -1 (0) :
>  Remote driver error: ClassCastException: java.lang.Long cannot be cast
>  to java.lang.Float
>          at org.apache.calcite.avatica.Helper.createException(Helper.java:54)
>          at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
>          at 
> org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:557)
>          at 
> org.apache.calcite.avatica.AvaticaPreparedStatement.executeQuery(AvaticaPreparedStatement.java:137)
>          at 
> com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.getCustomerByName(Payment.java:400)
>          at 
> com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.run(Payment.java:221)
>          at 
> com.oltpbenchmark.benchmarks.tpcc.TPCCWorker.executeWork(TPCCWorker.java:74)
>          at com.oltpbenchmark.api.Worker.doWork(Worker.java:386)
>          at com.oltpbenchmark.api.Worker.run(Worker.java:296)
>          at java.lang.Thread.run(Thread.java:748)
>  java.lang.ClassCastException: java.lang.Long cannot be cast to 
> java.lang.Float
>          at 
> org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:594)
>          at 
> org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:799)
>          at 
> org.apache.calcite.avatica.Meta$Frame.serializeScalar(Meta.java:985)
>          at org.apache.calcite.avatica.Meta$Frame.parseColumn(Meta.java:971)
>          at org.apache.calcite.avatica.Meta$Frame.toProto(Meta.java:936)
>          at 
> org.apache.calcite.avatica.remote.Service$ResultSetResponse.serialize(Service.java:841)
>          at 
> org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1158)
>          at 
> org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1113)
>          at 
> org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeResponse(ProtobufTranslationImpl.java:348)
>          at 
> org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:57)
>          at 
> org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:31)
>          at 
> org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:95)
>          at 
> org.apache.calcite.avatica.remote.ProtobufHandler.apply(ProtobufHandler.java:46)
>          at 
> org.apache.calcite.avatica.server.AvaticaProtobufHandler.handle(AvaticaProtobufHandler.java:127)
>          at 
> org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
>          at 
> 

[jira] [Created] (CALCITE-3506) Avatica: exception in the writetoProtoWithType function

2019-11-14 Thread Enrique Saurez (Jira)
Enrique Saurez created CALCITE-3506:
---

 Summary: Avatica: exception in the writetoProtoWithType function
 Key: CALCITE-3506
 URL: https://issues.apache.org/jira/browse/CALCITE-3506
 Project: Calcite
  Issue Type: Bug
  Components: avatica
Affects Versions: avatica-1.12.0
Reporter: Enrique Saurez


 am using Apache Calcite-Avatica version 1.12 (but the relevant code
 sections are not different from the master branch), and I am getting
 the following exception on the client side (but the actual error in on
 the server side):
 
||Exception||Heading 2||
|org.apache.calcite.avatica.AvaticaSqlException: Error -1 (0) :
 Remote driver error: ClassCastException: java.lang.Long cannot be cast
 to java.lang.Float
         at org.apache.calcite.avatica.Helper.createException(Helper.java:54)
         at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
         at 
org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:557)
         at 
org.apache.calcite.avatica.AvaticaPreparedStatement.executeQuery(AvaticaPreparedStatement.java:137)
         at 
com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.getCustomerByName(Payment.java:400)
         at 
com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.run(Payment.java:221)
         at 
com.oltpbenchmark.benchmarks.tpcc.TPCCWorker.executeWork(TPCCWorker.java:74)
         at com.oltpbenchmark.api.Worker.doWork(Worker.java:386)
         at com.oltpbenchmark.api.Worker.run(Worker.java:296)
         at java.lang.Thread.run(Thread.java:748)
 java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Float
         at 
org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:594)
         at 
org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:799)
         at org.apache.calcite.avatica.Meta$Frame.serializeScalar(Meta.java:985)
         at org.apache.calcite.avatica.Meta$Frame.parseColumn(Meta.java:971)
         at org.apache.calcite.avatica.Meta$Frame.toProto(Meta.java:936)
         at 
org.apache.calcite.avatica.remote.Service$ResultSetResponse.serialize(Service.java:841)
         at 
org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1158)
         at 
org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1113)
         at 
org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeResponse(ProtobufTranslationImpl.java:348)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:57)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:31)
         at 
org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:95)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.apply(ProtobufHandler.java:46)
         at 
org.apache.calcite.avatica.server.AvaticaProtobufHandler.handle(AvaticaProtobufHandler.java:127)
         at 
org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
         at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
         at org.eclipse.jetty.server.Server.handle(Server.java:499)
         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
         at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
         at 
[org.eclipse.jetty.io|http://org.eclipse.jetty.io/].AbstractConnection$2.run(AbstractConnection.java:544)
         at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
         at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
         at java.lang.Thread.run(Thread.java:748)|Col A2|


 From the code, it seems like when the function "writeToProtoWithType"
 is called from "toProto", there is a boxing conversion from long
 (primitive) to Long (object), this is because
 for floats, "toProto" is using "((Float) o).longValue()" which returns
 a long. Then in "writeToProtoWithType" is being casted to float, which
 I think causes the CastClassException.
 
 If I add this code to the testFloat() function in the
 "core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java"
 file:
 
{code:java}
Common.TypedValue.Builder builder = Common.TypedValue.newBuilder();
 Common.Rep val = TypedValue.toProto(builder, Float.valueOf(3.14159f));
 Common.TypedValue typedVal = builder.build();{code}
 

it replicates the exception. I am not sure why are you using the longValue() on 
the float within the toProto function? Doesn't this cast lose information? 
Please let me know if you need any more information. I send an email to the dev 
mailing list, but somebody suggested to create the issue here.


 Thanks a lot for help!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (CALCITE-3506) Avatica: exception in the writetoProtoWithType function

2019-11-14 Thread Enrique Saurez (Jira)


 [ 
https://issues.apache.org/jira/browse/CALCITE-3506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Enrique Saurez updated CALCITE-3506:

Description: 
 am using Apache Calcite-Avatica version 1.12 (but the relevant code
 sections are not different from the master branch), and I am getting
 the following exception on the client side (but the actual error in on
 the server side):
||Exception||
|org.apache.calcite.avatica.AvaticaSqlException: Error -1 (0) :
 Remote driver error: ClassCastException: java.lang.Long cannot be cast
 to java.lang.Float
         at org.apache.calcite.avatica.Helper.createException(Helper.java:54)
         at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
         at 
org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:557)
         at 
org.apache.calcite.avatica.AvaticaPreparedStatement.executeQuery(AvaticaPreparedStatement.java:137)
         at 
com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.getCustomerByName(Payment.java:400)
         at 
com.oltpbenchmark.benchmarks.tpcc.procedures.Payment.run(Payment.java:221)
         at 
com.oltpbenchmark.benchmarks.tpcc.TPCCWorker.executeWork(TPCCWorker.java:74)
         at com.oltpbenchmark.api.Worker.doWork(Worker.java:386)
         at com.oltpbenchmark.api.Worker.run(Worker.java:296)
         at java.lang.Thread.run(Thread.java:748)
 java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Float
         at 
org.apache.calcite.avatica.remote.TypedValue.writeToProtoWithType(TypedValue.java:594)
         at 
org.apache.calcite.avatica.remote.TypedValue.toProto(TypedValue.java:799)
         at org.apache.calcite.avatica.Meta$Frame.serializeScalar(Meta.java:985)
         at org.apache.calcite.avatica.Meta$Frame.parseColumn(Meta.java:971)
         at org.apache.calcite.avatica.Meta$Frame.toProto(Meta.java:936)
         at 
org.apache.calcite.avatica.remote.Service$ResultSetResponse.serialize(Service.java:841)
         at 
org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1158)
         at 
org.apache.calcite.avatica.remote.Service$ExecuteResponse.serialize(Service.java:1113)
         at 
org.apache.calcite.avatica.remote.ProtobufTranslationImpl.serializeResponse(ProtobufTranslationImpl.java:348)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:57)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.encode(ProtobufHandler.java:31)
         at 
org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:95)
         at 
org.apache.calcite.avatica.remote.ProtobufHandler.apply(ProtobufHandler.java:46)
         at 
org.apache.calcite.avatica.server.AvaticaProtobufHandler.handle(AvaticaProtobufHandler.java:127)
         at 
org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
         at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
         at org.eclipse.jetty.server.Server.handle(Server.java:499)
         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
         at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
         at 
[org.eclipse.jetty.io|http://org.eclipse.jetty.io/].AbstractConnection$2.run(AbstractConnection.java:544)
         at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
         at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
         at java.lang.Thread.run(Thread.java:748)|

>From the code, it seems like when the function "writeToProtoWithType"
 is called from "toProto", there is a boxing conversion from long
 (primitive) to Long (object), this is because
 for floats, "toProto" is using "((Float) o).longValue()" which returns
 a long. Then in "writeToProtoWithType" is being casted to float, which
 I think causes the CastClassException.

If I add this code to the testFloat() function in the
 "core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java"
 file:
{code:java}
Common.TypedValue.Builder builder = Common.TypedValue.newBuilder();
 Common.Rep val = TypedValue.toProto(builder, Float.valueOf(3.14159f));
 Common.TypedValue typedVal = builder.build();{code}
 

it replicates the exception. I am not sure why are you using the longValue() on 
the float within the toProto function? Doesn't this cast lose information? 
Please let me know if you need any more information. I send an email to the dev 
mailing list, but somebody suggested to create the issue here.

Thanks a lot for help!

  was:
 am using Apache Calcite-Avatica version 1.12 (but the relevant code
 sections are not different from the master branch), and I am getting
 the following exception on the client side (but the actual error in on
 the server side):
 
||Exception||Heading 2||
|org.apache.calcite.avatica.AvaticaSqlException: