MaxGekk 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_r264045333
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/TimestampFormatter.scala
##########
@@ -49,16 +49,16 @@ class Iso8601TimestampFormatter(
@transient
protected lazy val formatter = getOrCreateFormatter(pattern, locale)
- private def toInstant(s: String): Instant = {
- val temporalAccessor = formatter.parse(s)
- if (temporalAccessor.query(TemporalQueries.offset()) == null) {
- toInstantWithZoneId(temporalAccessor, timeZone.toZoneId)
- } else {
- Instant.from(temporalAccessor)
- }
- }
+ override def parse(s: String): Long = {
+ val parsed = formatter.parse(s)
+ val parsedZoneId = parsed.query(TemporalQueries.zone())
+ val zoneId = if (parsedZoneId == null) timeZone.toZoneId else parsedZoneId
Review comment:
> Do we need to evaluate timeZone.toZoneId everytime?
No, we don't.
> Can we evaluate this once and store this into val when this class is
instantiated?
Sure. Actually I think of go over all time-related code in a separate PR,
and try to replace `TimeZone` objects by `ZoneId` or even by `ZoneOffset`.
----------------------------------------------------------------
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]