Skip to content

Commit 2394047

Browse files
committed
[SPARK-19050][SS][TESTS] Fix EventTimeWatermarkSuite 'delay in months and years handled correctly'
## What changes were proposed in this pull request? `monthsSinceEpoch` in this test is like `math.floor(num)`, so `monthDiff` has two possible values. ## How was this patch tested? Jenkins. Author: Shixiong Zhu <[email protected]> Closes #16449 from zsxwing/watermark-test-hotfix.
1 parent 35e9740 commit 2394047

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ class EventTimeWatermarkSuite extends StreamTest with BeforeAndAfter with Loggin
190190
assertEventStats { e =>
191191
assert(timestampFormat.parse(e.get("max")).getTime === (currentTimeMs / 1000) * 1000)
192192
val watermarkTime = timestampFormat.parse(e.get("watermark"))
193-
assert(monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) === 29)
193+
val monthDiff = monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime)
194+
// monthsSinceEpoch is like `math.floor(num)`, so monthDiff has two possible values.
195+
assert(monthDiff === 29 || monthDiff === 30,
196+
s"currentTime: $currentTime, watermarkTime: $watermarkTime")
194197
}
195198
)
196199
}

0 commit comments

Comments
 (0)