1
0

Fix avro doesn't have short and byte byte.

This commit is contained in:
kaka11chen
2019-03-06 12:29:03 +08:00
committed by vinoth chandar
parent 3ae6cb4ed5
commit b514e1ab18

View File

@@ -265,8 +265,12 @@ object AvroConversionUtils {
case null => null case null => null
case bytes: Array[Byte] => ByteBuffer.wrap(bytes) case bytes: Array[Byte] => ByteBuffer.wrap(bytes)
} }
case ByteType | ShortType | IntegerType | LongType | case IntegerType | LongType |
FloatType | DoubleType | StringType | BooleanType => identity 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 _: DecimalType => (item: Any) => if (item == null) null else item.toString
case TimestampType => (item: Any) => case TimestampType => (item: Any) =>
if (item == null) null else item.asInstanceOf[Timestamp].getTime if (item == null) null else item.asInstanceOf[Timestamp].getTime