@@ -114,7 +114,8 @@ case class WindowExec(
114114 * @param bound with respect to the row.
115115 * @return a bound ordering object.
116116 */
117- private [this ] def createBoundOrdering (frame : FrameType , bound : Expression ): BoundOrdering = {
117+ private [this ] def createBoundOrdering (
118+ frame : FrameType , bound : Expression , timeZone : String ): BoundOrdering = {
118119 (frame, bound) match {
119120 case (RowFrame , CurrentRow ) =>
120121 RowBoundOrdering (0 )
@@ -144,7 +145,7 @@ case class WindowExec(
144145 val boundExpr = (expr.dataType, boundOffset.dataType) match {
145146 case (DateType , IntegerType ) => DateAdd (expr, boundOffset)
146147 case (TimestampType , CalendarIntervalType ) =>
147- TimeAdd (expr, boundOffset, Some (conf.sessionLocalTimeZone ))
148+ TimeAdd (expr, boundOffset, Some (timeZone ))
148149 case (a, b) if a== b => Add (expr, boundOffset)
149150 }
150151 val bound = newMutableProjection(boundExpr :: Nil , child.output)
@@ -197,6 +198,7 @@ case class WindowExec(
197198
198199 // Map the groups to a (unbound) expression and frame factory pair.
199200 var numExpressions = 0
201+ val timeZone = conf.sessionLocalTimeZone
200202 framedFunctions.toSeq.map {
201203 case (key, (expressions, functionSeq)) =>
202204 val ordinal = numExpressions
@@ -237,7 +239,7 @@ case class WindowExec(
237239 new UnboundedPrecedingWindowFunctionFrame (
238240 target,
239241 processor,
240- createBoundOrdering(frameType, upper))
242+ createBoundOrdering(frameType, upper, timeZone ))
241243 }
242244
243245 // Shrinking Frame.
@@ -246,7 +248,7 @@ case class WindowExec(
246248 new UnboundedFollowingWindowFunctionFrame (
247249 target,
248250 processor,
249- createBoundOrdering(frameType, lower))
251+ createBoundOrdering(frameType, lower, timeZone ))
250252 }
251253
252254 // Moving Frame.
@@ -255,8 +257,8 @@ case class WindowExec(
255257 new SlidingWindowFunctionFrame (
256258 target,
257259 processor,
258- createBoundOrdering(frameType, lower),
259- createBoundOrdering(frameType, upper))
260+ createBoundOrdering(frameType, lower, timeZone ),
261+ createBoundOrdering(frameType, upper, timeZone ))
260262 }
261263 }
262264
0 commit comments