From b514e1ab18415e3d369e3b836c14c7b1a9498cea Mon Sep 17 00:00:00 2001 From: kaka11chen Date: Wed, 6 Mar 2019 12:29:03 +0800 Subject: [PATCH] Fix avro doesn't have short and byte byte. --- .../main/scala/com/uber/hoodie/AvroConversionUtils.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hoodie-spark/src/main/scala/com/uber/hoodie/AvroConversionUtils.scala b/hoodie-spark/src/main/scala/com/uber/hoodie/AvroConversionUtils.scala index df3f96438..337ff6a5b 100644 --- a/hoodie-spark/src/main/scala/com/uber/hoodie/AvroConversionUtils.scala +++ b/hoodie-spark/src/main/scala/com/uber/hoodie/AvroConversionUtils.scala @@ -265,8 +265,12 @@ object AvroConversionUtils { case null => null case bytes: Array[Byte] => ByteBuffer.wrap(bytes) } - case ByteType | ShortType | IntegerType | LongType | + case IntegerType | LongType | FloatType | DoubleType | StringType | BooleanType => identity + case ByteType => (item: Any) => + if (item == null) null else item.asInstanceOf[Byte].intValue + case ShortType => (item: Any) => + if (item == null) null else item.asInstanceOf[Short].intValue case _: DecimalType => (item: Any) => if (item == null) null else item.toString case TimestampType => (item: Any) => if (item == null) null else item.asInstanceOf[Timestamp].getTime