cloud-fan commented on a change in pull request #24030: [SPARK-27109][SQL]
Refactoring of TimestampFormatter and DateFormatter
URL: https://github.com/apache/spark/pull/24030#discussion_r264082427
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeFormatterHelper.scala
##########
@@ -28,16 +28,21 @@ import com.google.common.cache.CacheBuilder
import org.apache.spark.sql.catalyst.util.DateTimeFormatterHelper._
trait DateTimeFormatterHelper {
- protected def toInstantWithZoneId(temporalAccessor: TemporalAccessor,
zoneId: ZoneId): Instant = {
- val localTime = if (temporalAccessor.query(TemporalQueries.localTime) ==
null) {
- LocalTime.ofNanoOfDay(0)
- } else {
- LocalTime.from(temporalAccessor)
- }
- val localDate = LocalDate.from(temporalAccessor)
- val localDateTime = LocalDateTime.of(localDate, localTime)
- val zonedDateTime = ZonedDateTime.of(localDateTime, zoneId)
- Instant.from(zonedDateTime)
+ // Sets hours, minutes, seconds and nanos of second to zeros
+ lazy val zeroLocalTime = LocalTime.ofNanoOfDay(0)
Review comment:
+1, lazy val is expensive.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]