Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21074#discussion_r182100748
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ---
    @@ -176,16 +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)
    -      // Currently we find the wider common type by comparing the two 
types from left to right,
    -      // this can be a problem when you have two data types which don't 
have a common type but each
    -      // can be promoted to StringType. For instance, (TimestampType, 
IntegerType, StringType)
    -      // should have StringType as the wider common type.
    -      case None if types.exists(_ == StringType) &&
    -        types.forall(stringPromotion(_, StringType).nonEmpty) => 
Some(StringType)
    -      case _ => 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 when each of the types is 
StringType or can be
    --- End diff --
    
    `This is only a problem for StringType`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to