[
https://issues.apache.org/jira/browse/HIVE-27004?focusedWorklogId=843076&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-843076
]
ASF GitHub Bot logged work on HIVE-27004:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 02/Feb/23 05:34
Start Date: 02/Feb/23 05:34
Worklog Time Spent: 10m
Work Description: AnmolSun opened a new pull request, #4008:
URL: https://github.com/apache/hive/pull/4008
…TC+' in Java versions higher than 8.
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/Hive/HowToContribute
2. Ensure that you have created an issue on the Hive project JIRA:
https://issues.apache.org/jira/projects/HIVE/summary
3. Ensure you have added or run the appropriate tests for your PR:
4. If the PR is unfinished, add '[WIP]' in your PR title, e.g.,
'[WIP]HIVE-XXXXX: Your PR title ...'.
5. Be sure to keep the PR description updated to reflect all changes.
6. Please write your PR title to summarize what this PR proposes.
7. If possible, provide a concise example to reproduce the issue for a
faster review.
-->
### What changes were proposed in this pull request?
Make changes in
_common/src/java/org/apache/hadoop/hive/common/type/TimestampTZUtil.java_ to
prevent
### Why are the changes needed?
Required to prevent parsing related error in Java ver greater than 8
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Tested at my setup with related unit tests that were failing on Java ver
greater than 8
Issue Time Tracking
-------------------
Worklog Id: (was: 843076)
Time Spent: 0.5h (was: 20m)
> 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: 0.5h
> 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)