wangyum commented on code in PR #40616:
URL: https://github.com/apache/spark/pull/40616#discussion_r1156585817


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala:
##########
@@ -1171,6 +1172,29 @@ object TypeCoercion extends TypeCoercionBase {
     }
   }
 
+  // For legacy support. For example: string type +/- interval.
+  object ResolveBinaryArithmetic extends TypeCoercionRule {
+    override val transform: PartialFunction[Expression, Expression] =
+      AnsiTypeCoercion.ResolveBinaryArithmetic.transform.andThen {
+        case a @ Add(l, r, _) if a.childrenResolved => (l.dataType, 
r.dataType) match {
+          case (StringType | _: NumericType | BinaryType | BooleanType,
+              CalendarIntervalType | _: DayTimeIntervalType) =>
+            Cast(TimeAdd(l, r), l.dataType)

Review Comment:
   For ANSI mode. It should be [DatetimeType and 
AnsiIntervalType](https://github.com/apache/spark/pull/40616/files#diff-2b33eb8ae2127bd8a3d461132f4db0c57c65419aebe2f4a14d595b6ea5cebf36R341-R343):
   For non-ANSI mode. It should be DatetimeType, AnsiIntervalType, StringType, 
NumericType, BinaryType and BooleanType.



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