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/17 05:56:07 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #28842: [SPARK-32006][SQL] Create date/timestamp formatters once before collect in `hiveResultString()`

cloud-fan commented on a change in pull request #28842:
URL: https://github.com/apache/spark/pull/28842#discussion_r441297086



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/HiveResult.scala
##########
@@ -72,47 +90,32 @@ object HiveResult {
     }
   }
 
-  // We can create the date formatter only once because it does not depend on Spark's
-  // session time zone controlled by the SQL config `spark.sql.session.timeZone`.
-  // The `zoneId` parameter is used only in parsing of special date values like `now`,
-  // `yesterday` and etc. but not in date formatting. While formatting of:
-  // - `java.time.LocalDate`, zone id is not used by `DateTimeFormatter` at all.
-  // - `java.sql.Date`, the date formatter delegates formatting to the legacy formatter
-  //   which uses the default system time zone `TimeZone.getDefault`. This works correctly
-  //   due to `DateTimeUtils.toJavaDate` which is based on the system time zone too.
-  private val dateFormatter = DateFormatter(
-    format = DateFormatter.defaultPattern,
-    // We can set any time zone id. UTC was taken for simplicity.
-    zoneId = ZoneOffset.UTC,
-    locale = DateFormatter.defaultLocale,
-    // Use `FastDateFormat` as the legacy formatter because it is thread-safe.
-    legacyFormat = LegacyDateFormats.FAST_DATE_FORMAT,
-    isParsing = false)
-  private def timestampFormatter = TimestampFormatter.getFractionFormatter(
-    DateTimeUtils.getZoneId(SQLConf.get.sessionLocalTimeZone))
-
   /** Formats a datum (based on the given data type) and returns the string representation. */
-  def toHiveString(a: (Any, DataType), nested: Boolean = false): String = a match {
+  def toHiveString(
+    a: (Any, DataType),

Review comment:
       nit: 4 space indentation




----------------------------------------------------------------
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