[ https://issues.apache.org/jira/browse/HIVE-27004?focusedWorklogId=843373&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-843373 ]
ASF GitHub Bot logged work on HIVE-27004: ----------------------------------------- Author: ASF GitHub Bot Created on: 03/Feb/23 04:45 Start Date: 03/Feb/23 04:45 Worklog Time Spent: 10m Work Description: saihemanth-cloudera merged PR #4008: URL: https://github.com/apache/hive/pull/4008 Issue Time Tracking ------------------- Worklog Id: (was: 843373) Time Spent: 50m (was: 40m) > DateTimeFormatterBuilder cannot parse 'UTC+' in Java versions higher than 8 > --------------------------------------------------------------------------- > > Key: HIVE-27004 > URL: https://issues.apache.org/jira/browse/HIVE-27004 > Project: Hive > Issue Type: Bug > Components: Hive > Environment: Java version used > {code:java} > openjdk version "11.0.16.1" 2022-08-12 LTS OpenJDK Runtime Environment > Corretto-11.0.16.9.1 (build 11.0.16.1+9-LTS) OpenJDK 64-Bit Server VM > Corretto-11.0.16.9.1 (build 11.0.16.1+9-LTS, mixed mode{code} > > Reporter: Anmol Sundaram > Assignee: Anmol Sundaram > Priority: Minor > Labels: pull-request-available > Attachments: HIVE-27004.patch > > Time Spent: 50m > Remaining Estimate: 0h > > Some of the unit tests related to _DateTimeFormatter_ were failing in Java > versions greater than 8 while working in Java 8. > Example of a failing Unit Test : > _org.apache.hadoop.hive.common.type.TestTimestampTZ#testComparision_ > > {code:java} > java.time.format.DateTimeParseException: Text '2017-04-14 18:00:00 UTC+08:00' > could not be parsed, unparsed text found at index 23 at > java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2049) > at > java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1874) > at > org.apache.hadoop.hive.common.type.TimestampTZUtil.parse(TimestampTZUtil.java:76) > at > org.apache.hadoop.hive.common.type.TimestampTZUtil.parse(TimestampTZUtil.java:64) > at > org.apache.hadoop.hive.common.type.TestTimestampTZ.testComparison(TestTimestampTZ.java:44) > at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method){code} > > The {{appendZoneText(TextStyle)}} method of > [DateTimeFormatteBuilder|https://github.com/apache/hive/blob/master/common/src/java/org/apache/hadoop/hive/common/type/TimestampTZUtil.java#L82] > is not able to parse the {{+}} symbol in {{2017-04-14 18:00:00 UTC+08:00}} > when running [the > test|https://github.com/apache/hive/blob/master/common/src/test/org/apache/hadoop/hive/common/type/TestTimestampTZ.java#L37] > in Java 11 , while it is working fine with Java 8. > According to the > [doc|https://developer.android.com/reference/java/time/format/DateTimeFormatterBuilder#appendZoneText(java.time.format.TextStyle)] > , {{appendZoneText(TextStyle)}} should be able to parse {{either the textual > zone name, the zone ID or the offset}} and UTC+08:00 should come under offset > as per the same > [doc|https://developer.android.com/reference/java/time/format/DateTimeFormatterBuilder#appendOffset(java.lang.String,%20java.lang.String)]. > It seems, however, that "UTC" was explicitly removed [when parsed as ZoneText > for higher Java > versions|https://github.com/openjdk/jdk/commit/5c3a01591c5c945926636fdc9f164d60b5b4f29e?diff=unified#diff-5fcf976db1c06e8f44a8671356d7e34fdfbf5b057baa852e7c3e015c8797c889R4263] > As a workaround, we can use {{appendZoneOrOffsetId()}} rather than > {{appendZoneText().}} > This ensures the tests are passing for Java 8+ and based on my testing, I > didn’t see any regression of the change. > Sample repro code - jdoodle.com/ia/D5e > -- This message was sent by Atlassian Jira (v8.20.10#820010)