bijection icon indicating copy to clipboard operation
bijection copied to clipboard

Deserializing Joda DateTime as Long type

Open mkhsueh opened this issue 9 years ago • 0 comments

Ran into this error deserializing Joda DateTime into an Avro model: java.lang.Long cannot be cast to org.joda.time.DateTime was able to serialize a record with this value: {"name": "eventTime", "type": {"type": "long", "logicalType": "timestamp-millis"}}, but calling injection.invert(the serialized byte[]).get() throws that error.

My injection object :

private static Injection<MyModel, byte[]> injection = SpecificAvroCodecs.toBinary(scala.reflect.ClassTag$.MODULE$.apply(MyModel.class)); 

Dug into the codebase ( DateBijectionLaws.scala ) looks like round trips were expected using 'String'. Changing the underlying Avro schema to type "string" worked. Should there be dual support for string/long given the timestamp-millis logical type?

Thanks, Michael

mkhsueh avatar Sep 19 '16 17:09 mkhsueh