cloud-fan 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_r292768996
##########
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:
Why can't we upcast null to other nullable types? I think it's pretty common
to write `INSERT INTO tbl VALUES (1, null)`
----------------------------------------------------------------
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]