hvanhovell commented on code in PR #47464:
URL: https://github.com/apache/spark/pull/47464#discussion_r1692320832


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTimeWindows.scala:
##########
@@ -257,10 +259,11 @@ object SessionWindowing extends Rule[LogicalPlan] {
           case s: SessionWindow => sessionAttr
         }
 
-        val filterByTimeRange = session.gapDuration match {
-          case Literal(interval: CalendarInterval, CalendarIntervalType) =>
-            interval == null || interval.months + interval.days + 
interval.microseconds <= 0
-          case _ => true
+        val filterByTimeRange = if (gapDuration.foldable) {

Review Comment:
   This is a bit better than pattern matching on a literal since it also 
supports more complex expressions, in particular `Cast(Literal("<some gap 
duration>r", StringType), CalendarIntervalType)`. Normally you'd expect the 
constant folding to take care of this, but this happens during optimization, 
and this rule is part of analysis; hence the need for manual constant folding.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTimeWindows.scala:
##########
@@ -257,10 +259,11 @@ object SessionWindowing extends Rule[LogicalPlan] {
           case s: SessionWindow => sessionAttr
         }
 
-        val filterByTimeRange = session.gapDuration match {
-          case Literal(interval: CalendarInterval, CalendarIntervalType) =>
-            interval == null || interval.months + interval.days + 
interval.microseconds <= 0
-          case _ => true
+        val filterByTimeRange = if (gapDuration.foldable) {

Review Comment:
   This is a bit better than pattern matching on a literal since it supports 
more complex expressions, in particular `Cast(Literal("<some gap duration>r", 
StringType), CalendarIntervalType)`. Normally you'd expect the constant folding 
to take care of this, but this happens during optimization, and this rule is 
part of analysis; hence the need for manual constant folding.



-- 
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-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to