gatorsmile commented on a change in pull request #21586: [SPARK-24586][SQL]
Upcast should not allow casting from string to other types
URL: https://github.com/apache/spark/pull/21586#discussion_r284842999
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -120,35 +120,36 @@ object Cast {
}
/**
- * Return true iff we may truncate during casting `from` type to `to` type.
e.g. long -> int,
- * timestamp -> date.
+ * Returns true iff we can safely up-cast the `from` type to `to` type
without any truncating or
+ * precision lose or possible runtime failures. For example, long -> int,
string -> int are not
+ * up-cast.
*/
- def mayTruncate(from: DataType, to: DataType): Boolean = (from, to) match {
Review comment:
I know this will be ugly, but I still prefer to adding a conf for falling
back to the original behavior.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]