Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][SQL] Refactor the implementation of SparkDateTimeUtils#toJavaDate #45817

Closed
wants to merge 4 commits into from

Conversation

LuciferYang
Copy link
Contributor

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

@github-actions github-actions bot added the SQL label Apr 2, 2024
@LuciferYang LuciferYang marked this pull request as draft April 2, 2024 11:50
@LuciferYang LuciferYang changed the title [WIP] Refactor the implementation of SparkDateTimeUtils#toJavaDate [WIP][SQL] Refactor the implementation of SparkDateTimeUtils#toJavaDate Apr 2, 2024
case timeZone: TimeZone =>
timeZone.getOffset(localMillis - timeZone.getRawOffset)
}
val timeZoneOffset = TimeZone.getDefault.getOffset(localMillis)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #45716, I replaced the direct call to sun.util.calendar.ZoneInfo with the use of MethodHandle in order to make Spark 4.0 to be build with -release.

However, referring to the fromJavaDate function, I wonder if we can directly use TimeZone.getDefault.getOffset(localMillis) here?

def fromJavaDate(date: Date): Int = {
val millisUtc = date.getTime
val millisLocal = millisUtc + TimeZone.getDefault.getOffset(millisUtc)
val julianDays = Math.toIntExact(Math.floorDiv(millisLocal, MILLIS_PER_DAY))
rebaseJulianToGregorianDays(julianDays)
}

All unit tests have passed with this pr. Is there any other reason that sun.util.calendar.ZoneInfo must be used here?

@hvanhovell @MaxGekk @dongjoon-hyun @HyukjinKwon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is feasible, I will update the PR description later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant