cloud-fan commented on a change in pull request #32170:
URL: https://github.com/apache/spark/pull/32170#discussion_r659901849



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -345,6 +345,8 @@ class Analyzer(override val catalogManager: CatalogManager)
     override def apply(plan: LogicalPlan): LogicalPlan = 
plan.resolveOperatorsUp {
       case p: LogicalPlan => p.transformExpressionsUp {
         case a @ Add(l, r, f) if a.childrenResolved => (l.dataType, 
r.dataType) match {
+          case (DateType, DayTimeIntervalType) => TimeAdd(Cast(l, 
TimestampType), r)
+          case (DayTimeIntervalType, DateType) => TimeAdd(Cast(r, 
TimestampType), l)

Review comment:
       I doubt this. For old interval types, `Date + Interval` always returns 
Date:
   ```
   case (DateType, CalendarIntervalType) => DateAddInterval(l, r, ansiEnabled = 
f)
   case (CalendarIntervalType, DateType) => DateAddInterval(r, l, ansiEnabled = 
f)
   ```
   
   I think we should do this for new interval types as well, and fail at 
runtime if the interval has hour, minute, second fields.




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