You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/06/01 08:06:41 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #28674: [SPARK-31868][SQL] Restore the parsing behaviour week-based-year for 2.4

yaooqinn commented on a change in pull request #28674:
URL: https://github.com/apache/spark/pull/28674#discussion_r433097046



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeFormatterHelper.scala
##########
@@ -31,26 +33,92 @@ import org.apache.spark.sql.internal.SQLConf
 import org.apache.spark.sql.internal.SQLConf.LegacyBehaviorPolicy._
 
 trait DateTimeFormatterHelper {
-  private def getOrDefault(accessor: TemporalAccessor, field: ChronoField, default: Int): Int = {
+  private def getFieldValue(
+      accessor: TemporalAccessor,
+      field: TemporalField): Option[Int] = {
     if (accessor.isSupported(field)) {
-      accessor.get(field)
+      try {
+        Option(accessor.get(field))
+      } catch {
+        case NonFatal(_) => None

Review comment:
       This is because for week-based fields it can be absent even if isSupported passes




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org