[ 
https://issues.apache.org/jira/browse/HIVE-26290?focusedWorklogId=778657&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-778657
 ]

ASF GitHub Bot logged work on HIVE-26290:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 06/Jun/22 14:58
            Start Date: 06/Jun/22 14:58
    Worklog Time Spent: 10m 
      Work Description: zabetak commented on code in PR #3342:
URL: https://github.com/apache/hive/pull/3342#discussion_r890241196


##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFFromUnixTime.java:
##########
@@ -99,7 +98,6 @@ public void configure(MapredContext context) {
     if (context != null) {
       String timeZoneStr = HiveConf.getVar(context.getJobConf(), 
HiveConf.ConfVars.HIVE_LOCAL_TIME_ZONE);
       timeZone = TimestampTZUtil.parseTimeZone(timeZoneStr);
-      FORMATTER.withZone(timeZone);

Review Comment:
   The part of the code that does the translation from a long representing 
epoch seconds to string on a specific `timeZone` (line 121 to 125), does not 
need the formatter to have specific timezone since it uses `ZonedDateTime`.
   
   Explicitly setting the formatter to the same timezone with `ZonedDateTime` 
does not alter the result as the following example illustrates: 
   
   ```java
       ZoneId singaporeZone = ZoneId.of("Asia/Singapore");
       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd 
HH:mm:ss");
   
       Instant instant = Instant.now();
       ZonedDateTime zonedDT = ZonedDateTime.ofInstant(instant, singaporeZone);
   
       System.out.println(zonedDT.format(formatter));
       System.out.println(zonedDT.format(formatter.withZone(singaporeZone)));
   ```
   It would make sense to set `FORMATTER` to a specific zone if it was 
different from the timezone in `ZonedDateTime`, but this is not the case here.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 778657)
    Time Spent: 0.5h  (was: 20m)

> Remove useless calls to DateTimeFormatter#withZone without assignment
> ---------------------------------------------------------------------
>
>                 Key: HIVE-26290
>                 URL: https://issues.apache.org/jira/browse/HIVE-26290
>             Project: Hive
>          Issue Type: Task
>          Components: HiveServer2
>            Reporter: Stamatis Zampetakis
>            Assignee: Stamatis Zampetakis
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> There are some places in the code calling \{{DateTimeFormatter#withZone}} 
> without assigning the result anywhere. This basically makes the call useless 
> since the method does not modify the formatter instance but always creates a 
> new one.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to