MaxGekk commented on a change in pull request #28687:
URL: https://github.com/apache/spark/pull/28687#discussion_r432981702



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/HiveResult.scala
##########
@@ -73,7 +73,13 @@ object HiveResult {
   }
 
   private def zoneId = 
DateTimeUtils.getZoneId(SQLConf.get.sessionLocalTimeZone)
-  private def dateFormatter = DateFormatter(zoneId)
+  // Date formatting does not depend on time zone ID because it converts local 
days
+  // since the epoch to local date string. Time zone id does matter only in 
parsing
+  // when the parser has to handle special values like `now`, `yesterday` and 
etc.
+  // Here, `dateFormatter` is used only for formatting, so, we can initialize 
it by
+  // any time zone once, for instance, by the current session time zone. And 
we can
+  // reuse it even when the session time zone might be changed.
+  private val dateFormatter = DateFormatter(zoneId)

Review comment:
       Just in case, can `hiveResultString()` or `toHiveString()` be called 
from multiple threads in parallel. If so, we cannot use SimpleDateFormat here 
because it is not thread-safe. In that case, dateFormatter must use 
`FastDateFormat` because it is thread-safe.




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to