-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31221][SQL] Rebase any date-times in conversions to/from Java types #27980
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
821ffb5
Rebase java date for whole range
MaxGekk 0b2dd01
Use localDateToDays()
MaxGekk 5e2148d
Rebase any date-time
MaxGekk b466cac
Fix tests
MaxGekk dd25238
Re-use rebase functions from DateTimeUtils in DaysWritable
MaxGekk 577303f
Remove unused const from DateTimeUtils
MaxGekk 0d4bc10
Add comments
MaxGekk a6420f2
Add comments to fromJavaDate and to toJavaDate
MaxGekk db89c92
Add comments to toJavaTimestamp and to fromJavaTimestamp
MaxGekk 6e8dba0
Use -08:00 instead of PST in a test
MaxGekk 46b6613
Use America/Los_Angeles instead of PST in a test
MaxGekk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,13 +88,9 @@ class DateTimeUtilsSuite extends SparkFunSuite with Matchers with SQLHelper { | |
| } | ||
|
|
||
| test("SPARK-6785: java date conversion before and after epoch") { | ||
| def format(d: Date): String = { | ||
| TimestampFormatter("yyyy-MM-dd", defaultTimeZone().toZoneId) | ||
| .format(millisToMicros(d.getTime)) | ||
| } | ||
| def checkFromToJavaDate(d1: Date): Unit = { | ||
| val d2 = toJavaDate(fromJavaDate(d1)) | ||
| assert(format(d2) === format(d1)) | ||
| assert(d2.toString === d1.toString) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| val df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US) | ||
|
|
@@ -500,17 +496,16 @@ class DateTimeUtilsSuite extends SparkFunSuite with Matchers with SQLHelper { | |
| } | ||
| } | ||
|
|
||
| withDefaultTimeZone(TimeZone.getTimeZone("PST")) { | ||
| val tz = "America/Los_Angeles" | ||
| withDefaultTimeZone(TimeZone.getTimeZone(tz)) { | ||
| // Daylight Saving Time | ||
| test("2016-03-13 01:59:59", "PST", "2016-03-13 09:59:59.0") | ||
| // 2016-03-13 02:00:00 PST does not exists | ||
| test("2016-03-13 02:00:00", "PST", "2016-03-13 10:00:00.0") | ||
| test("2016-03-13 03:00:00", "PST", "2016-03-13 10:00:00.0") | ||
| test("2016-11-06 00:59:59", "PST", "2016-11-06 07:59:59.0") | ||
| // 2016-11-06 01:00:00 PST could be 2016-11-06 08:00:00 UTC or 2016-11-06 09:00:00 UTC | ||
| test("2016-11-06 01:00:00", "PST", "2016-11-06 09:00:00.0") | ||
| test("2016-11-06 01:59:59", "PST", "2016-11-06 09:59:59.0") | ||
| test("2016-11-06 02:00:00", "PST", "2016-11-06 10:00:00.0") | ||
| test("2016-03-13 01:59:59", tz, "2016-03-13 09:59:59.0") | ||
| test("2016-03-13 02:00:00", tz, "2016-03-13 10:00:00.0") | ||
| test("2016-03-13 03:00:00", tz, "2016-03-13 10:00:00.0") | ||
| test("2016-11-06 00:59:59", tz, "2016-11-06 07:59:59.0") | ||
| test("2016-11-06 01:00:00", tz, "2016-11-06 08:00:00.0") | ||
| test("2016-11-06 01:59:59", tz, "2016-11-06 08:59:59.0") | ||
| test("2016-11-06 02:00:00", tz, "2016-11-06 10:00:00.0") | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the test because of the 2 lines. I wasn't able to build 2 timestamps via
Timestamp.valueOfafter rebasing.Timestampclass does normalization underneath, and replaces milliseconds since the epoch, and as a consequence of that checking of the results fails. Even textual representation, andyear,month, ...nanosare the same.