From 7d1cde4d2f5045a5d42ce3111101ec6c9595ab2e Mon Sep 17 00:00:00 2001 From: Maxim Gekk Date: Mon, 3 Sep 2018 11:37:28 +0200 Subject: [PATCH] Minor refactoring to reduce diff --- .../sql/catalyst/json/JacksonUtils.scala | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonUtils.scala index d438bccba911d..2d89c7066d080 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonUtils.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonUtils.scala @@ -32,23 +32,25 @@ object JacksonUtils { } } - def verifyType(name: String, dataType: DataType): Unit = dataType match { - case NullType | BooleanType | ByteType | ShortType | IntegerType | LongType | FloatType | - DoubleType | StringType | TimestampType | DateType | BinaryType | _: DecimalType => + def verifyType(name: String, dataType: DataType): Unit = { + dataType match { + case NullType | BooleanType | ByteType | ShortType | IntegerType | LongType | FloatType | + DoubleType | StringType | TimestampType | DateType | BinaryType | _: DecimalType => - case st: StructType => st.foreach(field => verifyType(field.name, field.dataType)) + case st: StructType => st.foreach(field => verifyType(field.name, field.dataType)) - case at: ArrayType => verifyType(name, at.elementType) + case at: ArrayType => verifyType(name, at.elementType) - // For MapType, its keys are treated as a string (i.e. calling `toString`) basically when - // generating JSON, so we only care if the values are valid for JSON. - case mt: MapType => verifyType(name, mt.valueType) + // For MapType, its keys are treated as a string (i.e. calling `toString`) basically when + // generating JSON, so we only care if the values are valid for JSON. + case mt: MapType => verifyType(name, mt.valueType) - case udt: UserDefinedType[_] => verifyType(name, udt.sqlType) + case udt: UserDefinedType[_] => verifyType(name, udt.sqlType) - case _ => - throw new UnsupportedOperationException( - s"Unable to convert column $name of type ${dataType.catalogString} to JSON.") + case _ => + throw new UnsupportedOperationException( + s"Unable to convert column $name of type ${dataType.catalogString} to JSON.") + } } /**