Skip to content

Conversation

@MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Feb 16, 2019

What changes were proposed in this pull request?

In the PR, I propose to convert time zone string to TimeZone by converting it to ZoneId which uses ZoneOffset internally. The ZoneOffset class of JDK 8 has a cache already: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/time/ZoneOffset.java#l205 . In this way, there is no need to support cache of time zones in Spark.

The PR removes computedTimeZones from DateTimeUtils, and uses ZoneId.of to convert time zone id string to ZoneId and to TimeZone at the end.

How was this patch tested?

The changes were tested by

@MaxGekk MaxGekk changed the title [SPARK-26903][SQL] Remove the cache of TimeZones [SPARK-26903][SQL] Remove the TimeZone cache Feb 16, 2019
@SparkQA
Copy link

SparkQA commented Feb 17, 2019

Test build #102422 has finished for PR 23812 at commit e4a40b6.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 17, 2019

Test build #102423 has finished for PR 23812 at commit f0e9d18.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 17, 2019

Test build #102427 has finished for PR 23812 at commit 37551d1.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: SimpleDateParam calls TimeZone.getTimeZone("GMT"). If you like you could make that a constant here or call to DateTimeUtils to fully remove those calls.

@srowen
Copy link
Member

srowen commented Feb 22, 2019

@MaxGekk I'll merge this with a rebase, and if you check out my few comments above

@SparkQA
Copy link

SparkQA commented Feb 22, 2019

Test build #102655 has finished for PR 23812 at commit 18e6e15.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

ToUTCTimestamp(
Literal(Timestamp.valueOf("2015-07-24 00:00:00")), Literal("\"quote")) :: Nil)
}.getMessage
assert(msg == "Invalid ID for region-based ZoneId, invalid format: \"quote")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small last one -- make this consistent with the test below and remove comment about escaping. In fact, maybe the bad zone ID should be obviously wrong, like "NoSuchZone"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a couple more test cases

@SparkQA
Copy link

SparkQA commented Feb 23, 2019

Test build #102698 has finished for PR 23812 at commit 9fded33.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Feb 23, 2019

Merged to master

@srowen srowen closed this in d0f2fd0 Feb 23, 2019
@MaxGekk MaxGekk deleted the timezone-cache branch September 18, 2019 15:56

def getTimeZone(timeZoneId: String): TimeZone = {
computedTimeZones.computeIfAbsent(timeZoneId, computeTimeZone)
val zoneId = ZoneId.of(timeZoneId, ZoneId.SHORT_IDS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MaxGekk after upgrading Spark 2.3 to Spark3.0, we found this behaviour change are rejecting some valid timeZoneIds, for example

// GMT+8:00 is a valid timezone if parsed from TimeZone.getTimeZone("GMT+8:00")
// However, ZoneId.of("GMT+8:00", ZoneId.SHORT_IDS) are rejected with an exception
from_unix_time("2020-01-01 10:00:00", "GMT+8:00")

what do you think about support these kind of timezones, such as GMT+8:00?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants