From 75ff69a9940776f0337a080b721d45d9f571c386 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Thu, 15 Jul 2021 11:40:51 +0300 Subject: [PATCH] [SPARK-36037][TESTS][FOLLOWUP] Avoid wrong test results on daylight saving time ### What changes were proposed in this pull request? Only use the zone ids that has no daylight saving for testing `localtimestamp` ### Why are the changes needed? https://github.com/apache/spark/pull/33346#discussion_r670135296 MaxGekk suggests that we should avoid wrong results if possible. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Unit test Closes #33354 from gengliangwang/FIxDST. Authored-by: Gengliang Wang Signed-off-by: Max Gekk (cherry picked from commit 564d3de7c62fa89c6db1e08e809400b339a704cd) Signed-off-by: Max Gekk --- .../spark/sql/catalyst/expressions/DateExpressionsSuite.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala index dbfe0af337..eecaa930d1 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala @@ -97,7 +97,8 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { } test("datetime function localtimestamp") { - outstandingTimezonesIds.foreach { zid => + // Verify with multiple outstanding time zones which has no daylight saving time. + Seq("UTC", "Africa/Dakar", "Asia/Hong_Kong").foreach { zid => val zoneId = DateTimeUtils.getZoneId(zid) val ct = LocalTimestamp(Some(zid)).eval(EmptyRow).asInstanceOf[Long] val t1 = DateTimeUtils.localDateTimeToMicros(LocalDateTime.now(zoneId))