You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2018/06/01 00:43:39 UTC

[GitHub] spark pull request #21470: [SPARK-24443][SQL] comparison should accept struc...

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

    https://github.com/apache/spark/pull/21470#discussion_r192274662
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala ---
    @@ -803,18 +803,60 @@ object TypeCoercion {
               e.copy(left = Cast(e.left, TimestampType))
             }
     
    -      case b @ BinaryOperator(left, right) if left.dataType != right.dataType =>
    -        findTightestCommonType(left.dataType, right.dataType).map { commonType =>
    -          if (b.inputType.acceptsType(commonType)) {
    -            // If the expression accepts the tightest common type, cast to that.
    -            val newLeft = if (left.dataType == commonType) left else Cast(left, commonType)
    -            val newRight = if (right.dataType == commonType) right else Cast(right, commonType)
    -            b.withNewChildren(Seq(newLeft, newRight))
    -          } else {
    -            // Otherwise, don't do anything with the expression.
    -            b
    -          }
    -        }.getOrElse(b)  // If there is no applicable conversion, leave expression unchanged.
    +      case b @ BinaryOperator(left, right)
    +          if !BinaryOperator.sameType(left.dataType, right.dataType) =>
    --- End diff --
    
    `findTightestCommonType` doesn't accept struct type with different filed names, so the other code are needed.


---

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