srowen commented on code in PR #39843:
URL: https://github.com/apache/spark/pull/39843#discussion_r1094623314
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTimeWindows.scala:
##########
@@ -103,9 +115,10 @@ object TimeWindowing extends Rule[LogicalPlan] {
def getWindow(i: Int, dataType: DataType): Expression = {
val timestamp = PreciseTimestampConversion(window.timeColumn,
dataType, LongType)
- val lastStart = timestamp - (timestamp - window.startTime
- + window.slideDuration) % window.slideDuration
- val windowStart = lastStart - i * window.slideDuration
+ val lastStart = timestamp - (timestamp - window.startTime) %
window.slideDuration
Review Comment:
This seems a little complicated, and need not involve CaseWhen. You just
always want to subtract a nonnegative amount here.
```
val remainder = (timestamp - window.startTime) % window.slideDuration
val lastStart = timestamp - (if (remainder < 0) remainder +
window.slideDuration else remainder)
```
--
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]