You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/06/03 08:06:36 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #28709: [WIP][SQL] Make legacy date formatters independent from the default JVM time zone

MaxGekk commented on a change in pull request #28709:
URL: https://github.com/apache/spark/pull/28709#discussion_r434383930



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/util/DateFormatterSuite.scala
##########
@@ -169,19 +175,22 @@ class DateFormatterSuite extends SparkFunSuite with SQLHelper {
   test("SPARK-31557: rebasing in legacy formatters/parsers") {
     withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> LegacyBehaviorPolicy.LEGACY.toString) {
       LegacyDateFormats.values.foreach { legacyFormat =>
-        outstandingTimezonesIds.foreach { timeZone =>
-          withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> timeZone) {
-            val formatter = DateFormatter(
-              DateFormatter.defaultPattern,
-              getZoneId(timeZone),
-              DateFormatter.defaultLocale,
-              legacyFormat,
-              isParsing = false)
-            assert(LocalDate.ofEpochDay(formatter.parse("1000-01-01")) === LocalDate.of(1000, 1, 1))
-            assert(formatter.format(LocalDate.of(1000, 1, 1)) === "1000-01-01")
-            assert(formatter.format(localDateToDays(LocalDate.of(1000, 1, 1))) === "1000-01-01")
-            assert(formatter.format(java.sql.Date.valueOf("1000-01-01")) === "1000-01-01")
-          }
+        withOutstandingZoneIds { zoneId =>
+          val formatter = DateFormatter(
+            DateFormatter.defaultPattern,
+            zoneId,
+            DateFormatter.defaultLocale,
+            legacyFormat,
+            isParsing = false)
+          assert(LocalDate.ofEpochDay(formatter.parse("1000-01-01")) === LocalDate.of(1000, 1, 1))
+          assert(formatter.format(LocalDate.of(1000, 1, 1)) === "1000-01-01")
+          assert(formatter.format(localDateToDays(LocalDate.of(1000, 1, 1))) === "1000-01-01")
+          val cal = new Calendar.Builder()

Review comment:
       The time zone is embedded into `java.sql.Date`, and it is the global default JVM time zone. To set tested time zone, I have to construct Date via the calendar.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org