MaxGekk commented on a change in pull request #23391: [SPARK-26456][SQL] Cast 
date/timestamp to string by Date/TimestampFormatter
URL: https://github.com/apache/spark/pull/23391#discussion_r244421218
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ##########
 @@ -230,12 +230,15 @@ case class Cast(child: Expression, dataType: DataType, 
timeZoneId: Option[String
   // [[func]] assumes the input is no longer null because eval already does 
the null check.
   @inline private[this] def buildCast[T](a: Any, func: T => Any): Any = 
func(a.asInstanceOf[T])
 
+  private val dateFormatter = DateFormatter()
 
 Review comment:
   It can be lazy as well but I don't see reasons for that:
   - Lazy vals are not for free: 
http://rgg.zone/2016/12/06/scala-the-cost-of-laziness/
   - `DateFormatter` is serializable and can be transferred to executors
   - Instance of `DateFormatter` shouldn't consume much memory, so, we can 
instantiate it in the constructor.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to