[
https://issues.apache.org/jira/browse/HIVE-9792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Dere updated HIVE-9792:
-----------------------------
Attachment: HIVE-9792.1.patch
Attaching initial patch.
This adds 2 separate interval types:
- year-month interval, which represents a date difference in years and months.
Internally represented as an offset of months.
- day-time interval, which represents a date difference in
days/hours/minutes/seconds/nanoseconds. 1 day = 24 hours = 1440 minutes = 86400
seconds. Internally represented as an offset of seconds (long) and nanoseconds
(int).
I've tried using the Oracle's [Datetime and Interval
Arithmetic|http://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006312]
rules with regard to timestamp arithmetic, where the timestamp arithmetic is
done in UTC time. This results in similar behavior to below depending on the
default time zone in Hive:
{noformat}
SQL> select timestamp '1999-09-15 00:00:00 America/Los_Angeles' - timestamp
'1999-12-15 00:00:00 America/Los_Angeles' from dual;
TIMESTAMP'1999-09-1500:00:00AMERICA/LOS_ANGELES'-TIMESTAMP'1999-12-1500:00:
---------------------------------------------------------------------------
-000000091 01:00:00.000000000
SQL> select timestamp '1999-09-15 00:00:00 UTC' - timestamp '1999-12-15
00:00:00 UTC' from dual;
TIMESTAMP'1999-09-1500:00:00UTC'-TIMESTAMP'1999-12-1500:00:00UTC'
---------------------------------------------------------------------------
-000000091 00:00:00.000000000
{noformat}
Unlike Oracle, however, date '2001-01-31' + interval '1' month returns date
'2001-02-28', whereas this causes an error in Oracle.
> Support interval type in expressions/predicates
> ------------------------------------------------
>
> Key: HIVE-9792
> URL: https://issues.apache.org/jira/browse/HIVE-9792
> Project: Hive
> Issue Type: Sub-task
> Components: Types
> Reporter: Jason Dere
> Assignee: Jason Dere
> Attachments: HIVE-9792.1.patch
>
>
> Provide partial support for the interval year-month/interval day-time types
> in Hive. Intervals will be usable in expressions/predicates/joins:
> {noformat}
> select birthdate + interval '30-0' year to month as thirtieth_birthday
> from table
> where (current_timestamp - ts1 < interval '3 0:0:0' day to second)
> {noformat}
> This stops short of adding making the interval types usable as a storable
> column type.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)