hovosgithub / hive-json-serde

Automatically exported from code.google.com/p/hive-json-serde
0 stars 0 forks source link

ClassCastException: java.lang.Integer cannot be cast to java.lang.Long #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
One of my fields are of type bigint in Hive. When running  a query over that 
table I get the following exception.

I assumed that the JSON library reads the field as an Integer and when Hive 
expects a Long things blow up. Tried changing the field to int in Hive, but 
then I get the reversed class cast exception. Also tried making it a string in 
Hive, but then it also fails with a class cast exception.

java.io.IOException: java.lang.ClassCastException: java.lang.Integer cannot be 
cast to java.lang.Long
    at org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:137)
    at org.apache.hadoop.hive.ql.Driver.getResults(Driver.java:684)
    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:146)
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:197)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:302)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to 
java.lang.Long
    at org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaLongObjectInspector.get(JavaLongObjectInspector.java:39)
    at org.apache.hadoop.hive.serde2.lazy.LazyUtils.writePrimitiveUTF8(LazyUtils.java:190)
    at org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.serialize(LazySimpleSerDe.java:480)
    at org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.serialize(LazySimpleSerDe.java:426)
    at org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:129)
    ... 9 more

Original issue reported on code.google.com by johan%os...@gtempaccount.com on 10 Sep 2010 at 1:09

GoogleCodeExporter commented 8 years ago
I looked through the json reading code (outside the serde) and as suspected it 
assumes the value is an integer if it can. This patch adds a special case in 
the serde if a value is returned as int when it should be long. There might be 
a cleaner solution but this works fine for my current needs.

Original comment by johan%os...@gtempaccount.com on 11 Sep 2010 at 3:01

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by pas...@gmail.com on 22 Dec 2010 at 12:11

GoogleCodeExporter commented 8 years ago
It seems that there are multiple type conversion issues. I am fixing the 
primitive ones now.

Original comment by pas...@gmail.com on 22 Dec 2010 at 1:28

GoogleCodeExporter commented 8 years ago
With check in r13 this is complete.

Original comment by pas...@gmail.com on 22 Dec 2010 at 1:30