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

    https://github.com/apache/spark/pull/21074#discussion_r182458121
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ---
    @@ -175,11 +175,27 @@ object TypeCoercion {
           })
       }
     
    +  /**
    +   * Whether the data type contains StringType.
    +   */
    +  def hasStringType(dt: DataType): Boolean = dt match {
    +    case StringType => true
    +    case ArrayType(et, _) => hasStringType(et)
    +    // Add StructType if we support string promotion for struct fields in 
the future.
    +    case _ => false
    +  }
    +
       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,
    --- End diff --
    
    `This is only a problem for StringType or nested StringType in ArrayType. 
Excluding these types, ...`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to