simhadri-g commented on code in PR #5241:
URL: https://github.com/apache/hive/pull/5241#discussion_r1601448040
##########
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTimeUtils.java:
##########
@@ -119,7 +128,44 @@ public static Timestamp getTimestamp(NanoTime nt, ZoneId
targetZone, boolean leg
calendar.set(Calendar.SECOND, seconds);
Timestamp ts = Timestamp.ofEpochMilli(calendar.getTimeInMillis(), (int)
nanos);
- ts = TimestampTZUtil.convertTimestampToZone(ts, ZoneOffset.UTC,
targetZone, legacyConversion);
+ ts = TimestampTZUtil.convertTimestampToZone(ts, ZoneOffset.UTC,
targetZone, legacyConversion)
+ .minusDays(leapYearDateAdjustment);
+
return ts;
}
+
+ private static int julianLeapYearAdjustment(JulianDate jDateTime) {
+ Set<Integer> validDaysOfMonth = new HashSet<>();
+ validDaysOfMonth.add(1);
+ validDaysOfMonth.add(2);
+ validDaysOfMonth.add(27);
+ validDaysOfMonth.add(28);
+ validDaysOfMonth.add(29);
+ LocalDateTime localDateTime;
+ try {
+ localDateTime = jDateTime.toLocalDateTime();
+ } catch (DateTimeException e) {
+ if (e.getMessage().contains(ErrorMsg.NOT_LEAP_YEAR.getMsg())) {
+ return 2;
+ } else {
+ throw e;
+ }
+ }
+
+ int year = localDateTime.getYear();
+ int dayOfMonth = localDateTime.getDayOfMonth();
+ boolean isJulianLeapYear = (year % 4 == 0 && year % 400 != 0 && year % 100
== 0);
+
+ if (year < 1582 && isJulianLeapYear &&
validDaysOfMonth.contains(dayOfMonth)) {
+ switch (localDateTime.getMonth()) {
+ case FEBRUARY:
+ return -2;
+ case MARCH:
+ return 2;
+ default:
+ return 0;
+ }
+ }
+ return 0;
+ }
Review Comment:
Yes, this is a jodd time issue cause by this change in jodd time:
https://github.com/oblac/jodd/commit/3d9772d8be3a974bd49eef29c26c086bbb0aad1a
In the jodd change mentioned above , they have moved from
jodd.datetime.JDateTime to java.time.LocalDateTime and LocalDateTime doesn't
gracefully handle julian leap year dates such as 200-02-29 .
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]