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/04/14 05:25:58 UTC
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #28189:
[SPARK-31426][SQL] Fix perf regressions of toJavaTimestamp/fromJavaTimestamp
dongjoon-hyun commented on a change in pull request #28189: [SPARK-31426][SQL] Fix perf regressions of toJavaTimestamp/fromJavaTimestamp
URL: https://github.com/apache/spark/pull/28189#discussion_r407874752
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -172,17 +176,8 @@ object DateTimeUtils {
* @return The number of micros since epoch from `java.sql.Timestamp`.
*/
def fromJavaTimestamp(t: Timestamp): SQLTimestamp = {
- val era = if (t.before(julianCommonEraStart)) 0 else 1
- val localDateTime = LocalDateTime.of(
- t.getYear + 1900, t.getMonth + 1, 1,
- t.getHours, t.getMinutes, t.getSeconds, t.getNanos)
- .`with`(ChronoField.ERA, era)
- // Add days separately to convert dates existed in Julian calendar but not
- // in Proleptic Gregorian calendar. For example, 1000-02-29 is valid date
- // in Julian calendar because 1000 is a leap year but 1000 is not a leap
- // year in Proleptic Gregorian calendar. And 1000-02-29 doesn't exist in it.
- .plusDays(t.getDate - 1) // Returns the next valid date after `date.getDate - 1` days
- instantToMicros(localDateTime.atZone(ZoneId.systemDefault).toInstant)
+ val micros = millisToMicros(t.getTime) + (t.getNanos / NANOS_PER_MICROS) % MICROS_PER_MILLIS
Review comment:
This seems to be the root cause.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org