jackylee-ch commented on code in PR #40790:
URL: https://github.com/apache/spark/pull/40790#discussion_r1169827216
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -396,6 +396,22 @@ object Cast extends QueryErrorsBase {
case (_, to: DecimalType) if !canNullSafeCastToDecimal(from, to) => true
case (_: FractionalType, _: IntegralType) => true // NaN, infinity
+
+ case (_: ArrayType, _: ArrayType) => false
+ case (_: MapType, _: MapType) => false
+ case (_: StructType, _: StructType) => false
+ case (_: ArrayType | _: MapType | _: StructType, _) => true
+
+ case (DateType | TimestampType, TimestampNTZType) => false
+ case (_, TimestampNTZType) => true
+ case (TimestampNTZType, DateType | TimestampType) => false
+ case (TimestampNTZType, _) => true
+
+ case (_: IntegralType | _: DecimalType, _: AnsiIntervalType) => false
+ case (_, _: AnsiIntervalType) => true
+ case (_: AnsiIntervalType, _: IntegralType | _: DecimalType) => false
+ case (_: AnsiIntervalType, _) => true
+
Review Comment:
Hm. It is a little hard to add a test for this, as the nullable cases
encountered by different type conversions are different. Any better idea for
this?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]