hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mingran wang (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HIVE-1253) date_sub() function returns wrong date because of daylight saving time difference
Date Wed, 17 Mar 2010 23:30:27 GMT

    [ https://issues.apache.org/jira/browse/HIVE-1253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846669#action_12846669
] 

mingran wang commented on HIVE-1253:
------------------------------------

To get to the bottom of this, the formatter (SimpleDateFormat) interprets the time string
as local time zone, when it sets the calendar, it is PDT time zone (7 hours difference from
UTC), and when it substracts 7 days and convert back to formatter string, it converts UTC
to PST (still the local time zone, but different time zone now, and 8 hours difference from
UTC).

For the purpose of this function, since it is doing simple date_sub function, there is no
need to consider time zone at all, and all time zone should give the same result for this
kind of computation. For this reason, using default time zone would be fine, and we have to
use default time zone because formatter is using it.

> date_sub() function returns wrong date because of daylight saving time difference
> ---------------------------------------------------------------------------------
>
>                 Key: HIVE-1253
>                 URL: https://issues.apache.org/jira/browse/HIVE-1253
>             Project: Hadoop Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.5.0
>            Reporter: mingran wang
>
> date_sub('2010-03-15', 7) returns '2010-03-07'. This is because we have time shifts on
2010-03-14 for daylight saving time.
> Looking at ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDateSub.java, it is getting a
calendar instance in UTC time zone.
> def calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
> And use calendar.add() to substract 7 days, then conver the time to 'yyyy-MM-dd' format.
> If it simply uses default timezone, the problem is solved: "def calendar = Calendar.getInstance());"
> When people use date_sub('2010-03-15', 7), I think they mean substract 7 days, instead
of substracting 7*24 hours. So it should be an easy fix. The same changes should go to date_add
and date_diff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message