[SPARK-36037][SQL][FOLLOWUP] Fix flaky test for datetime function localtimestamp

### What changes were proposed in this pull request?

The threshold of the test case "datetime function localtimestamp" is small, which leads to flaky test results
https://github.com/gengliangwang/spark/runs/3067396143?check_suite_focus=true

This PR is to increase the threshold for checking two the different current local datetimes from 5ms to 1 second. (The test case of current_timestamp uses 5 seconds)
### Why are the changes needed?

Fix flaky test
### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Unit test

Closes #33346 from gengliangwang/fixFlaky.

Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
(cherry picked from commit 0973397721)
Signed-off-by: Gengliang Wang <gengliang@apache.org>
This commit is contained in:
Gengliang Wang 2021-07-15 11:32:18 +08:00
parent 8b35bc4d2b
commit 83b37dfaf0

View file

@ -98,10 +98,10 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
test("datetime function localtimestamp") { test("datetime function localtimestamp") {
outstandingTimezonesIds.foreach { zid => outstandingTimezonesIds.foreach { zid =>
val zoneId = DateTimeUtils.getZoneId(zid)
val ct = LocalTimestamp(Some(zid)).eval(EmptyRow).asInstanceOf[Long] val ct = LocalTimestamp(Some(zid)).eval(EmptyRow).asInstanceOf[Long]
val t1 = DateTimeUtils.localDateTimeToMicros( val t1 = DateTimeUtils.localDateTimeToMicros(LocalDateTime.now(zoneId))
LocalDateTime.now(DateTimeUtils.getZoneId(zid))) assert(math.abs(t1 - ct) < 1000000)
assert(math.abs(t1 - ct) < 5000)
} }
} }