Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19873#discussion_r155130916
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ---
    @@ -321,39 +319,40 @@ object TypeCoercion {
           }
         }
     
    -    override protected def coerceTypes(plan: LogicalPlan): LogicalPlan = 
plan resolveExpressions {
    -      // Skip nodes who's children have not been resolved yet.
    -      case e if !e.childrenResolved => e
    -
    -      case a @ BinaryArithmetic(left @ StringType(), right) =>
    -        a.makeCopy(Array(Cast(left, DoubleType), right))
    -      case a @ BinaryArithmetic(left, right @ StringType()) =>
    -        a.makeCopy(Array(left, Cast(right, DoubleType)))
    -
    -      // For equality between string and timestamp we cast the string to a 
timestamp
    -      // so that things like rounding of subsecond precision does not 
affect the comparison.
    -      case p @ Equality(left @ StringType(), right @ TimestampType()) =>
    -        p.makeCopy(Array(Cast(left, TimestampType), right))
    -      case p @ Equality(left @ TimestampType(), right @ StringType()) =>
    -        p.makeCopy(Array(left, Cast(right, TimestampType)))
    -
    -      case p @ BinaryComparison(left, right)
    -        if findCommonTypeForBinaryComparison(left.dataType, 
right.dataType).isDefined =>
    -        val commonType = findCommonTypeForBinaryComparison(left.dataType, 
right.dataType).get
    -        p.makeCopy(Array(castExpr(left, commonType), castExpr(right, 
commonType)))
    -
    -      case Abs(e @ StringType()) => Abs(Cast(e, DoubleType))
    -      case Sum(e @ StringType()) => Sum(Cast(e, DoubleType))
    -      case Average(e @ StringType()) => Average(Cast(e, DoubleType))
    -      case StddevPop(e @ StringType()) => StddevPop(Cast(e, DoubleType))
    -      case StddevSamp(e @ StringType()) => StddevSamp(Cast(e, DoubleType))
    -      case UnaryMinus(e @ StringType()) => UnaryMinus(Cast(e, DoubleType))
    -      case UnaryPositive(e @ StringType()) => UnaryPositive(Cast(e, 
DoubleType))
    -      case VariancePop(e @ StringType()) => VariancePop(Cast(e, 
DoubleType))
    -      case VarianceSamp(e @ StringType()) => VarianceSamp(Cast(e, 
DoubleType))
    -      case Skewness(e @ StringType()) => Skewness(Cast(e, DoubleType))
    -      case Kurtosis(e @ StringType()) => Kurtosis(Cast(e, DoubleType))
    -    }
    +    override protected def coerceTypes(plan: LogicalPlan): LogicalPlan =
    +      plan transformAllExpressions {
    --- End diff --
    
    For indentation...


---

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

Reply via email to