[SPARK-30865][SQL][SS] Refactor DateTimeUtils#27617
Conversation
|
Test build #118615 has finished for PR 27617 at commit
|
|
jenkins, retest this, please |
|
Test build #118623 has finished for PR 27617 at commit
|
|
@cloud-fan @HyukjinKwon Please, take a look at this PR. |
|
Test build #118757 has finished for PR 27617 at commit
|
|
Test build #118759 has finished for PR 27617 at commit
|
|
jenkins, retest this, please |
|
Test build #118768 has finished for PR 27617 at commit
|
|
Test build #118804 has finished for PR 27617 at commit
|
|
cc: @viirya @cloud-fan |
A bit confused. |
viirya
left a comment
There was a problem hiding this comment.
looks good except few minor comments.
|
Test build #124138 has finished for PR 27617 at commit
|
|
@cloud-fan @HyukjinKwon It is ready already. Can we continue with this PR? |
| tf.format(us) | ||
| // Converts the `micros` timestamp to string according to Hive TimestampWritable convention. | ||
| def timestampToString(tf: TimestampFormatter, micros: Long): String = { | ||
| tf.format(micros) |
There was a problem hiding this comment.
tf.format(micros) is shorter than timestampToString, do we really need this method?
|
|
||
| def microsToEpochDays(epochMicros: SQLTimestamp, zoneId: ZoneId): SQLDate = { | ||
| localDateToDays(microsToInstant(epochMicros).atZone(zoneId).toLocalDate) | ||
| def microsToEpochDays(micros: Long, zoneId: ZoneId): Int = { |
There was a problem hiding this comment.
is it the same with microsToDays?
There was a problem hiding this comment.
I removed the duplicates
|
|
||
| def epochDaysToMicros(epochDays: SQLDate, zoneId: ZoneId): SQLTimestamp = { | ||
| val localDate = LocalDate.ofEpochDay(epochDays) | ||
| def epochDaysToMicros(days: Int, zoneId: ZoneId): Long = { |
| def microsToEpochDays(epochMicros: SQLTimestamp, zoneId: ZoneId): SQLDate = { | ||
| localDateToDays(microsToInstant(epochMicros).atZone(zoneId).toLocalDate) | ||
| def microsToEpochDays(micros: Long, zoneId: ZoneId): Int = { | ||
| localDateToDays(microsToInstant(micros).atZone(zoneId).toLocalDate) |
There was a problem hiding this comment.
nit: localDateToDays(getLocalDateTime(micros, zoneId))
| def convertTz(ts: SQLTimestamp, fromZone: ZoneId, toZone: ZoneId): SQLTimestamp = { | ||
| val rebasedDateTime = microsToInstant(ts).atZone(toZone).toLocalDateTime.atZone(fromZone) | ||
| def convertTz(micros: Long, fromZone: ZoneId, toZone: ZoneId): Long = { | ||
| val rebasedDateTime = microsToInstant(micros).atZone(toZone).toLocalDateTime.atZone(fromZone) |
There was a problem hiding this comment.
nit: we can reuse getLocalDateTime here.
|
Test build #124234 has finished for PR 27617 at commit
|
|
Test build #124235 has finished for PR 27617 at commit
|
|
thanks, merging to master! |
What changes were proposed in this pull request?
*DateTimeUtils.in fromJulianDay()DateTimeUtils.subtractDates()julianCommonEraStart,timestampToString(),microsToEpochDays(),epochDaysToMicros(),instantToDays()fromDateTimeUtils.def daysToMicros(days: Int): Longanddef microsToDays(micros: Long): Int.Why are the changes needed?
This simplifies the common code related to date-time operations, and should improve maintainability. In particular:
millisToDaysanddaysToMillison Java 8 time API #27494, Spark expressions and DateTimeUtils functions switched to ZoneId instead of TimeZone completely.defaultTimeZone()withTimeZoneas return type is not needed anymore.*DateTimeUtils.in fromJulianDay().DateTimeUtils.subtractDates().Does this PR introduce any user-facing change?
No
How was this patch tested?
By existing test suites