Github user ckadner commented on the issue:
https://github.com/apache/spark/pull/13652
@davies ...just to confirm the desired behavior of these two test cases
```from UTC timestamp``` and ```to UTC timestamp```. We are contending with 3
time zones:
* we are parsing ```Timestamp```s from ```String```s in any/all time zones
in the Java world (```DateTimeTestUtils.ALL_TIMEZONES)```) so that they
represent the human readable time in any/each of those time zones which we are
iterating over (*)
* but in the inner ```test``` method we are treating these timestamps
```utc: String```as if they were created in ```UTC```
* then we are converting these timestamps (of "mistaken identity") to yet
another time zone ```tz: String``` (i.e. ```"UTC", "JST", "PST",
"Asia/Shanghai"```) and generating the human readable time in the time zone of
the for-loop (```DateTimeTestUtils.withDefaultTimeZone(tz)```)
```scala
test("from UTC timestamp") {
def test(utc: String, tz: String, expected: String): Unit = {
assert(toJavaTimestamp(fromUTCTime(fromJavaTimestamp(Timestamp.valueOf(utc)),
tz)).toString
=== expected)
}
for (tz <- DateTimeTestUtils.ALL_TIMEZONES) {
DateTimeTestUtils.withDefaultTimeZone(tz) {
test("2011-12-25 09:00:00.123456", "UTC", "2011-12-25
09:00:00.123456")
test("2011-12-25 09:00:00.123456", "JST", "2011-12-25
18:00:00.123456")
test("2011-12-25 09:00:00.123456", "PST", "2011-12-25
01:00:00.123456")
test("2011-12-25 09:00:00.123456", "Asia/Shanghai", "2011-12-25
17:00:00.123456")
}
}
...
```
(*) Before your fix (without the for-loop) the third time zone involved was
determined by the user's JVM default Timezone.
If this 3-timezone behavior is what we want to test, then should you
replace the two occurrences of ...
```scala
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone("PST")) {
```
with ...
```scala
for (tz <- DateTimeTestUtils.ALL_TIMEZONES) {
DateTimeTestUtils.withDefaultTimeZone(tz) {
```
... or would ```2016-03-13 02:00:00 PST``` and ```2016-11-06 01:00:00
PST``` not work?
```scala
DateTimeTestUtils.withDefaultTimeZone(TimeZone.getTimeZone("PST")) {
// Daylight Saving Time
test("2016-03-13 01:59:59", "PST", "2016-03-13 09:59:59.0")
// 2016-03-13 02:00:00 PST does not exists
test("2016-03-13 02:00:00", "PST", "2016-03-13 10:00:00.0")
test("2016-03-13 03:00:00", "PST", "2016-03-13 10:00:00.0")
test("2016-11-06 00:59:59", "PST", "2016-11-06 07:59:59.0")
// 2016-11-06 01:00:00 PST could be 2016-11-06 08:00:00 UTC or
2016-11-06 09:00:00 UTC
test("2016-11-06 01:00:00", "PST", "2016-11-06 09:00:00.0")
test("2016-11-06 01:59:59", "PST", "2016-11-06 09:59:59.0")
test("2016-11-06 02:00:00", "PST", "2016-11-06 10:00:00.0")
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]