Skip to content

Commit 55e18b6

Browse files
committed
Fix test
1 parent a0187cd commit 55e18b6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/RebaseDateTimeSuite.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,22 +421,24 @@ class RebaseDateTimeSuite extends SparkFunSuite with Matchers with SQLHelper {
421421
var ldt = LocalDateTime.of(1945, 11, 18, 1, 30, 0)
422422
var earlierMicros = instantToMicros(ldt.atZone(hkZid).withEarlierOffsetAtOverlap().toInstant)
423423
var laterMicros = instantToMicros(ldt.atZone(hkZid).withLaterOffsetAtOverlap().toInstant)
424-
if (earlierMicros + MICROS_PER_HOUR != laterMicros) {
424+
var overlapInterval = MICROS_PER_HOUR
425+
if (earlierMicros + overlapInterval != laterMicros) {
425426
// Old JDK might have an outdated time zone database.
426427
// See https://bugs.openjdk.java.net/browse/JDK-8228469: "Hong Kong ... Its 1945 transition
427428
// from JST to HKT was on 11-18 at 02:00, not 09-15 at 00:00"
428429
expected = "1945-09-14 23:30:00.0"
429430
ldt = LocalDateTime.of(1945, 9, 14, 23, 30, 0)
430431
earlierMicros = instantToMicros(ldt.atZone(hkZid).withEarlierOffsetAtOverlap().toInstant)
431432
laterMicros = instantToMicros(ldt.atZone(hkZid).withLaterOffsetAtOverlap().toInstant)
432-
assert(earlierMicros + MICROS_PER_HOUR === laterMicros)
433+
// If time zone db doesn't have overlapping at all, set the overlap interval to zero.
434+
overlapInterval = laterMicros - earlierMicros
433435
}
434436
val rebasedEarlierMicros = rebaseGregorianToJulianMicros(hkZid, earlierMicros)
435437
val rebasedLaterMicros = rebaseGregorianToJulianMicros(hkZid, laterMicros)
436438
def toTsStr(micros: Long): String = toJavaTimestamp(micros).toString
437439
assert(toTsStr(rebasedEarlierMicros) === expected)
438440
assert(toTsStr(rebasedLaterMicros) === expected)
439-
assert(rebasedEarlierMicros + MICROS_PER_HOUR === rebasedLaterMicros)
441+
assert(rebasedEarlierMicros + overlapInterval === rebasedLaterMicros)
440442
// Check optimized rebasing
441443
assert(rebaseGregorianToJulianMicros(earlierMicros) === rebasedEarlierMicros)
442444
assert(rebaseGregorianToJulianMicros(laterMicros) === rebasedLaterMicros)

0 commit comments

Comments
 (0)