Skip to content
Permalink
Browse files

[SPARK-24950][SQL] DateTimeUtilsSuite daysToMillis and millisToDays f…

…ails w/java 8 181-b13

- Update DateTimeUtilsSuite so that when testing roundtripping in daysToMillis and millisToDays multiple skipdates can be specified.
- Updated test so that both new years eve 2014 and new years day 2015 are skipped for kiribati time zones.  This is necessary as java versions pre 181-b13 considered new years day 2015 to be skipped while susequent versions corrected this to new years eve.

Unit tests

Author: Chris Martin <chris@cmartinit.co.uk>

Closes #21901 from d80tb7/SPARK-24950_datetimeUtilsSuite_failures.

(cherry picked from commit c5b8d54)
Signed-off-by: Sean Owen <srowen@gmail.com>
  • Loading branch information...
Chris Martin authored and srowen committed Jul 28, 2018
1 parent b2e0f68 commit 42229430f94ba33fb614628b9438e699b4922099
@@ -538,19 +538,19 @@ class DateTimeUtilsSuite extends SparkFunSuite {

test("daysToMillis and millisToDays") {
// There are some days are skipped entirely in some timezone, skip them here.
val skipped_days = Map[String, Int](
"Kwajalein" -> 8632,
"Pacific/Apia" -> 15338,
"Pacific/Enderbury" -> 9131,
"Pacific/Fakaofo" -> 15338,
"Pacific/Kiritimati" -> 9131,
"Pacific/Kwajalein" -> 8632,
"MIT" -> 15338)
val skipped_days = Map[String, Set[Int]](
"Kwajalein" -> Set(8632),
"Pacific/Apia" -> Set(15338),
"Pacific/Enderbury" -> Set(9130, 9131),
"Pacific/Fakaofo" -> Set(15338),
"Pacific/Kiritimati" -> Set(9130, 9131),
"Pacific/Kwajalein" -> Set(8632),
"MIT" -> Set(15338))
for (tz <- DateTimeTestUtils.ALL_TIMEZONES) {
DateTimeTestUtils.withDefaultTimeZone(tz) {
val skipped = skipped_days.getOrElse(tz.getID, Int.MinValue)
val skipped = skipped_days.getOrElse(tz.getID, Set.empty)
(-20000 to 20000).foreach { d =>
if (d != skipped) {
if (!skipped.contains(d)) {
assert(millisToDays(daysToMillis(d)) === d,
s"Round trip of ${d} did not work in tz ${tz}")
}

0 comments on commit 4222943

Please sign in to comment.
You can’t perform that action at this time.