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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to