kiszk commented on a change in pull request #28212: [WIP][SPARK-31443][SQL] Fix
perf regression of toJavaDate
URL: https://github.com/apache/spark/pull/28212#discussion_r408330328
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -127,8 +129,13 @@ object DateTimeUtils {
* @return A `java.sql.Date` from number of days since epoch.
*/
def toJavaDate(daysSinceEpoch: SQLDate): Date = {
- val localDate = LocalDate.ofEpochDay(daysSinceEpoch)
- new Date(localDate.getYear - 1900, localDate.getMonthValue - 1,
localDate.getDayOfMonth)
+ val rebasedDays = rebaseGregorianToJulianDays(daysSinceEpoch)
+ val localMillis = Math.multiplyExact(rebasedDays, MILLIS_PER_DAY)
+ val timeZoneOffset = TimeZone.getDefault match {
+ case zoneInfo: ZoneInfo => zoneInfo.getOffsetsByWall(localMillis, null)
+ case timeZone: TimeZone => timeZone.getOffset(localMillis -
timeZone.getRawOffset)
+ }
Review comment:
According to https://spark.apache.org/versioning-policy.html,, a maintenance
release would not include performance improvement patch.
For 3.0, it looks good due to the small size of this change.
----------------------------------------------------------------
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]