Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16777#discussion_r100690775 --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala --- @@ -379,6 +386,67 @@ class TypeCoercionSuite extends PlanTest { widenTest(ArrayType(IntegerType), StructType(Seq()), None) } + test("wider common type for decimal and array") { + def widenTestWithStringPromotion( + t1: DataType, + t2: DataType, + expected: Option[DataType]): Unit = { + checkWidenType(TypeCoercion.findWiderTypeForTwo, t1, t2, expected) + } + + def widenTestWithoutStringPromotion( + t1: DataType, + t2: DataType, + expected: Option[DataType]): Unit = { + checkWidenType(TypeCoercion.findWiderTypeWithoutStringPromotionForTwo, t1, t2, expected) + } + + // Decimal + widenTestWithStringPromotion( + DecimalType(2, 1), DecimalType(3, 2), Some(DecimalType(3, 2))) + widenTestWithStringPromotion( + DecimalType(2, 1), DoubleType, Some(DoubleType)) + widenTestWithStringPromotion( + DecimalType(2, 1), IntegerType, Some(DecimalType(11, 1))) + widenTestWithStringPromotion( + DoubleType, DecimalType(2, 1), Some(DoubleType)) + widenTestWithStringPromotion( + LongType, DecimalType(2, 1), Some(DecimalType(21, 1))) + + // ArrayType + widenTestWithStringPromotion( + ArrayType(ShortType, containsNull = true), + ArrayType(DoubleType, containsNull = false), + Some(ArrayType(DoubleType, containsNull = true))) + widenTestWithStringPromotion( + ArrayType(TimestampType, containsNull = false), + ArrayType(StringType, containsNull = true), + Some(ArrayType(StringType, containsNull = true))) + widenTestWithStringPromotion( + ArrayType(ArrayType(IntegerType), containsNull = false), + ArrayType(ArrayType(LongType), containsNull = false), + Some(ArrayType(ArrayType(LongType), containsNull = false))) + + // Without string promotion + widenTestWithoutStringPromotion(IntegerType, StringType, None) --- End diff -- `LongType` test was removed.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org