@@ -284,7 +284,7 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
284284 p
285285 } else if (childOutputDataTypes.size == tableOutputDataTypes.size &&
286286 childOutputDataTypes.zip(tableOutputDataTypes)
287- .forall( InsertIntoHiveType .equalsIgnoreNullability) ) {
287+ .forall { case (left, right) => DataType .equalsIgnoreNullability(left, right) } ) {
288288 // If both types ignoring nullability of ArrayType, MapType, StructType are the same,
289289 // use InsertIntoHiveTable instead of InsertIntoTable.
290290 InsertIntoHiveTable (p.table, p.partition, p.child, p.overwrite)
@@ -335,28 +335,7 @@ private[hive] case class InsertIntoHiveTable(
335335
336336 override lazy val resolved = childrenResolved && child.output.zip(table.output).forall {
337337 case (childAttr, tableAttr) =>
338- InsertIntoHiveType .equalsIgnoreNullability(childAttr.dataType, tableAttr.dataType)
339- }
340- }
341-
342- private [hive] object InsertIntoHiveType {
343-
344- /**
345- * Compares two types, ignoring nullability of ArrayType, MapType, StructType.
346- */
347- def equalsIgnoreNullability (dataTypePair : (DataType , DataType )): Boolean = {
348- dataTypePair match {
349- case (ArrayType (leftElementType, _), ArrayType (rightElementType, _)) =>
350- equalsIgnoreNullability(leftElementType, rightElementType)
351- case (MapType (leftKeyType, leftValueType, _), MapType (rightKeyType, rightValueType, _)) =>
352- equalsIgnoreNullability(leftKeyType, rightKeyType) &&
353- equalsIgnoreNullability(leftValueType, rightValueType)
354- case (StructType (leftFields), StructType (rightFields)) =>
355- leftFields.size == rightFields.size &&
356- leftFields.map(_.dataType).zip(rightFields.map(_.dataType))
357- .forall(equalsIgnoreNullability)
358- case (left, right) => left == right
359- }
338+ DataType .equalsIgnoreNullability(childAttr.dataType, tableAttr.dataType)
360339 }
361340}
362341
0 commit comments