Github user jiangxb1987 commented on a diff in the pull request: https://github.com/apache/spark/pull/21074#discussion_r182295312 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala --- @@ -176,10 +176,16 @@ object TypeCoercion { } private def findWiderCommonType(types: Seq[DataType]): Option[DataType] = { - types.foldLeft[Option[DataType]](Some(NullType))((r, c) => r match { - case Some(d) => findWiderTypeForTwo(d, c) - case None => None - }) + // findWiderTypeForTwo doesn't satisfy the associative law, i.e. (a op b) op c may not equal + // to a op (b op c). This is only a problem for StringType. Excluding StringType, + // findWiderTypeForTwo satisfies the associative law. For instance, (TimestampType, + // IntegerType, StringType) should have StringType as the wider common type. + val (stringTypes, nonStringTypes) = types.partition(_ == StringType) --- End diff -- It's expected to , let me also fix it for array types. Thanks!
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org