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 2019/07/24 14:20:21 UTC

[GitHub] [spark] gengliangwang commented on a change in pull request #25242: [SPARK-28497][SQL] Disallow upcasting complex data types to string type

gengliangwang commented on a change in pull request #25242: [SPARK-28497][SQL] Disallow upcasting complex data types to string type
URL: https://github.com/apache/spark/pull/25242#discussion_r306836526
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ##########
 @@ -131,7 +131,8 @@ object Cast {
     case (from: DecimalType, to: NumericType) if from.isTighterThan(to) => true
     case (f, t) if legalNumericPrecedence(f, t) => true
     case (DateType, TimestampType) => true
-    case (_, StringType) => true
+    case (_: AtomicType, StringType) => true
+    case (_: CalendarIntervalType, StringType) => true
 
 Review comment:
   I don't think it is valid up-cast.
   Even in `Cast`, Spark only allows casting to the same udt.
   ```
   case udt: UserDefinedType[_]
             if udt.userClass == from.asInstanceOf[UserDefinedType[_]].userClass =>
             identity[Any]
   case _: UserDefinedType[_] =>
             throw new SparkException(s"Cannot cast $from to $to.")
   ```

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


With regards,
Apache Git Services

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