You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/02/23 08:02:17 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #31349: [SPARK-34246][SQL] New type coercion syntax rules in ANSI mode

cloud-fan commented on a change in pull request #31349:
URL: https://github.com/apache/spark/pull/31349#discussion_r580830998



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
##########
@@ -182,65 +108,24 @@ object TypeCoercion {
   }
 
   /**
-   * The method finds a common type for data types that differ only in nullable flags, including
-   * `nullable`, `containsNull` of [[ArrayType]] and `valueContainsNull` of [[MapType]].
-   * If the input types are different besides nullable flags, None is returned.
+   * Finds a wider type when one or both types are decimals. If the wider decimal type exceeds
+   * system limitation, this rule will truncate the decimal type. If a decimal and other fractional
+   * types are compared, returns a double type.
    */
-  def findCommonTypeDifferentOnlyInNullFlags(t1: DataType, t2: DataType): Option[DataType] = {
-    if (t1 == t2) {
-      Some(t1)
-    } else {
-      findTypeForComplex(t1, t2, findCommonTypeDifferentOnlyInNullFlags)
-    }
-  }
-
-  def findCommonTypeDifferentOnlyInNullFlags(types: Seq[DataType]): Option[DataType] = {
-    if (types.isEmpty) {
-      None
-    } else {
-      types.tail.foldLeft[Option[DataType]](Some(types.head)) {
-        case (Some(t1), t2) => findCommonTypeDifferentOnlyInNullFlags(t1, t2)
-        case _ => None
-      }
+  def findWiderTypeForDecimal(dt1: DataType, dt2: DataType): Option[DataType] = {

Review comment:
       this can be protected.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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