You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2023/04/21 06:42:39 UTC

[GitHub] [spark] LuciferYang commented on a diff in pull request #40790: [SPARK-43116][SQL] Fix Cast.forceNullable

LuciferYang commented on code in PR #40790:
URL: https://github.com/apache/spark/pull/40790#discussion_r1173364511


##########
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?
   
   friendly ping @wangyum , any better suggestion?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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