Skip to content

Commit 9df8c84

Browse files
author
Davies Liu
committed
skip some days in tests
1 parent f23b545 commit 9df8c84

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ object DateTimeUtils {
851851
}
852852

853853
/**
854-
* Lookup the offset for given millis seconds since 1970-01-01 00:00:00 in a timezone.
854+
* Lookup the offset for given millis seconds since 1970-01-01 00:00:00 in given timezone.
855855
*/
856856
private def getOffsetFromLocalMillis(millisLocal: Long, tz: TimeZone): Long = {
857857
var guess = tz.getRawOffset

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,22 @@ class DateTimeUtilsSuite extends SparkFunSuite {
524524
}
525525

526526
test("daysToMillis and millisToDays") {
527-
for (tz <- DateTimeTestUtils.ALL_TIMEZONES) {
527+
// There are some days are skipped entirely in some timezone, skip them here.
528+
val skipped_days = Map[String, Int](
529+
"Kwajalein" -> 8632,
530+
"Pacific/Apia" -> 15338,
531+
"Pacific/Enderbury" -> 9131,
532+
"Pacific/Fakaofo" -> 15338,
533+
"Pacific/Kiritimati" -> 9131,
534+
"Pacific/Kwajalein" -> 8632,
535+
"MIT" -> 15338)
536+
for (tz <- DateTimeTestUtils.ALL_TIMEZONES) {
528537
DateTimeTestUtils.withDefaultTimeZone(tz) {
529-
(-2000 to 2000).foreach { d =>
530-
assert(millisToDays(daysToMillis(d)) === d)
538+
val skipped = skipped_days.getOrElse(tz.getID, Int.MinValue)
539+
(-20000 to 20000).foreach { d =>
540+
if (d != skipped) {
541+
assert(millisToDays(daysToMillis(d)) === d)
542+
}
531543
}
532544
}
533545
}

0 commit comments

Comments
 (0)