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/06/28 15:41:51 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #32170: [SPARK-35051][SQL] Support add/subtract of a day-time interval to/from a date

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