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

    https://github.com/apache/spark/pull/16777#discussion_r100861589
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ---
    @@ -117,49 +115,67 @@ object TypeCoercion {
        * loss of precision when widening decimal and double, and promotion to 
string.
        */
       private[analysis] def findWiderTypeForTwo(t1: DataType, t2: DataType): 
Option[DataType] = {
    -    (t1, t2) match {
    -      case (t1: DecimalType, t2: DecimalType) =>
    -        Some(DecimalPrecision.widerDecimalType(t1, t2))
    -      case (t: IntegralType, d: DecimalType) =>
    -        Some(DecimalPrecision.widerDecimalType(DecimalType.forType(t), d))
    -      case (d: DecimalType, t: IntegralType) =>
    -        Some(DecimalPrecision.widerDecimalType(DecimalType.forType(t), d))
    -      case (_: FractionalType, _: DecimalType) | (_: DecimalType, _: 
FractionalType) =>
    -        Some(DoubleType)
    -      case _ =>
    -        findTightestCommonTypeToString(t1, t2)
    -    }
    +    findTightestCommonType(t1, t2)
    +      .orElse(findWiderTypeForDecimal(t1, t2))
    --- End diff --
    
    yea we changed the order, but looks like it won't change the result. 
`findWiderTypeForDecimal` will always return a result for decimal type and 
numeric type, and if `findTightestCommonType` can return a result, 
`findWiderTypeForDecimal` will return the same result. So it doesn't matter if 
we run `findTightestCommonType` before or after it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to