gengliangwang commented on a change in pull request #34976:
URL: https://github.com/apache/spark/pull/34976#discussion_r773589688



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -192,31 +192,33 @@ object Cast {
    * In practice, the behavior is mostly the same as PostgreSQL. It disallows 
certain unreasonable
    * type conversions such as converting `string` to `int` or `double` to 
`boolean`.
    */
-  def canANSIStoreAssign(from: DataType, to: DataType): Boolean = (from, to) 
match {
-    case _ if from == to => true
-    case (NullType, _) => true
-    case (_: NumericType, _: NumericType) => true
-    case (_: AtomicType, StringType) => true
-    case (_: CalendarIntervalType, StringType) => true
-    case (DateType, TimestampType) => true
-    case (TimestampType, DateType) => true
-
-    case (ArrayType(fromType, fn), ArrayType(toType, tn)) =>
-      resolvableNullability(fn, tn) && canANSIStoreAssign(fromType, toType)
-
-    case (MapType(fromKey, fromValue, fn), MapType(toKey, toValue, tn)) =>
-      resolvableNullability(fn, tn) && canANSIStoreAssign(fromKey, toKey) &&
-        canANSIStoreAssign(fromValue, toValue)
-
-    case (StructType(fromFields), StructType(toFields)) =>
-      fromFields.length == toFields.length &&
-        fromFields.zip(toFields).forall {
-          case (f1, f2) =>
-            resolvableNullability(f1.nullable, f2.nullable) &&
-              canANSIStoreAssign(f1.dataType, f2.dataType)
-        }
+  def canANSIStoreAssign(from: DataType, to: DataType): Boolean = {
+    val dateTimeTypes = Seq(DateType, TimestampType, TimestampNTZType)

Review comment:
       Sure, updated.

##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeWriteCompatibilitySuite.scala
##########
@@ -154,6 +154,15 @@ class ANSIDataTypeWriteCompatibilitySuite extends 
DataTypeWriteCompatibilityBase
     }
   }
 
+  test("Check date time types compatible with each other") {

Review comment:
       updated




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

Reply via email to