Skip to content

Commit 83bf58b

Browse files
committed
Additional fallback
1 parent 1dd9ed1 commit 83bf58b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,14 @@ class LegacyFallbackDateFormatter(
154154
timeZone: TimeZone,
155155
locale: Locale) extends LegacyDateFormatter(pattern, timeZone, locale) {
156156
override def parse(s: String): Int = {
157-
Try(super.parse(s)).getOrElse {
158-
DateTimeUtils.millisToDays(DateTimeUtils.stringToTime(s).getTime)
157+
Try(super.parse(s)).orElse {
158+
// If it fails to parse, then tries the way used in 2.0 and 1.x for backwards
159+
// compatibility.
160+
Try(DateTimeUtils.millisToDays(DateTimeUtils.stringToTime(s).getTime))
161+
}.getOrElse {
162+
// In Spark 1.5.0, we store the data as number of days since epoch in string.
163+
// So, we just convert it to Int.
164+
s.toInt
159165
}
160166
}
161167
}

0 commit comments

Comments
 (0)