Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast error serializing Joda Datetime #259

Open
mkhsueh opened this issue Aug 24, 2016 · 1 comment
Open

Cast error serializing Joda Datetime #259

mkhsueh opened this issue Aug 24, 2016 · 1 comment

Comments

@mkhsueh
Copy link

mkhsueh commented Aug 24, 2016

Hello, I'm running into an issue serializing org.joda.time.DateTime through Kryo on Java; it appears to fail casting the java model DateTime to long. Does the library support this? Thanks!

In a Spark Kryo registration class:

 kryo.register(Foo.class, AvroSerializer.SpecificRecordBinarySerializer(scala.reflect.ClassTag$.MODULE$.apply(Foo.class)));

Where Foo is generated from Avro schema. The field in question is

{"name": "myField", "type": {"type": "long", "logicalType": "timestamp-millis"}},

When serialization is attempted, I end up with this stack:

java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.lang.Long
    at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:79)
    at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:114)
    at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:104)
    at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:66)
    at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:58)
    at com.twitter.bijection.avro.BinaryAvroCodec.apply(AvroCodecs.scala:273)
    at com.twitter.bijection.avro.BinaryAvroCodec.apply(AvroCodecs.scala:269)
    at com.twitter.chill.InjectiveSerializer.write(InjectiveSerializer.scala:24)
    at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)
    at org.apache.spark.serializer.KryoSerializationStream.writeObject(KryoSerializer.scala:195)
...
@magro
Copy link

magro commented Aug 25, 2016

JFYI, https://github.com/magro/kryo-serializers provides a kryo "native" serializer for joda DateTime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants