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 2020/05/19 06:25:50 UTC

[GitHub] [spark] Ngone51 commented on a change in pull request #28572: [SPARK-31750][SQL] Eliminate UpCast if child's dataType is DecimalType

Ngone51 commented on a change in pull request #28572:
URL: https://github.com/apache/spark/pull/28572#discussion_r427057191



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -3071,15 +3071,31 @@ class Analyzer(
       case p => p transformExpressions {
         case u @ UpCast(child, _, _) if !child.resolved => u
 
-        case UpCast(child, dt: AtomicType, _)
+        case u @ UpCast(child, _, _)
             if SQLConf.get.getConf(SQLConf.LEGACY_LOOSE_UPCAST) &&
+              u.dataType.isInstanceOf[AtomicType] &&
               child.dataType == StringType =>
-          Cast(child, dt.asNullable)
-
-        case UpCast(child, dataType, walkedTypePath) if !Cast.canUpCast(child.dataType, dataType) =>
-          fail(child, dataType, walkedTypePath)
-
-        case UpCast(child, dataType, _) => Cast(child, dataType.asNullable)
+          Cast(child, u.dataType.asNullable)
+
+        case u @ UpCast(child, _, walkedTypePath)
+          if child.dataType.isInstanceOf[DecimalType]
+            && u.dataType.isInstanceOf[DecimalType]
+            && walkedTypePath.nonEmpty =>

Review comment:
       It's more like a sanity check to prevent the case of using `UpCast` outside of `ExpressionEncoder` in the future.




----------------------------------------------------------------
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