gengliangwang commented on a change in pull request #24806: 
[WIP][SPARK-27856][SQL] Only allow type upcasting when inserting table
URL: https://github.com/apache/spark/pull/24806#discussion_r292786952
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ##########
 @@ -128,8 +128,10 @@ object Cast {
     case _ if from == to => true
     case (from: NumericType, to: DecimalType) if to.isWiderThan(from) => true
     case (from: DecimalType, to: NumericType) if from.isTighterThan(to) => true
-    case (f, t) if legalNumericPrecedence(f, t) => true
+    case (f: NumericType, t: NumericType) if legalNumericPrecedence(f, t) => 
true
+
     case (DateType, TimestampType) => true
+    case (NullType, _) => false
 
 Review comment:
   Here we can't know the nullability of the `to` type. We should consider it 
is not nullable.
   For the case you mentioned, it is handled in 
https://github.com/apache/spark/pull/24806/files#diff-86e655772e8f7cab055d2c2451b52275R134.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to