You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/12/21 19:14:51 UTC
[GitHub] [spark] MaxGekk commented on a change in pull request #34976: [SPARK-37707][SQL] Allow store assignment between TimestampNTZ and Date/Timestamp
MaxGekk commented on a change in pull request #34976:
URL: https://github.com/apache/spark/pull/34976#discussion_r773383599
##########
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:
How about to add new class/trait `DateTimeType` (or some other name) like `AnyTimestampType` or `AnsiIntervalType`, and check it here. Even for now, I have found a few place where all those types are checked together.
--
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