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

Carter Shanklin commented on HIVE-13557:
----------------------------------------

Hive supports interval but only with the singular forms, which is annoying.

Hive:
{code}
hive> select date '2012-01-01' + interval '-30' day;
OK
2011-12-02 00:00:00
Time taken: 0.506 seconds, Fetched: 1 row(s)
hive> select date '2012-01-01' + interval '-30' days;
NoViableAltException(146@[323:1: atomExpression : ( ( KW_NULL )=> KW_NULL -> 
TOK_NULL | ( constant )=> constant | castExpression | caseExpression | 
whenExpression | ( functionName LPAREN )=> function | tableOrColumn | LPAREN ! 
expression RPAREN !);])
.... long traceback truncated
{code}

Same is true of month and year. Hive doesn't support either "week" or "weeks" 
like other databases do.

Compare Postgres:
{code}
vagrant=# select date '2012-01-01' + (-30) days;
    days
------------
 2011-12-02
(1 row)

vagrant=# select date '2012-01-01' + interval '-30' day;
      ?column?
---------------------
 2011-12-02 00:00:00
(1 row)

vagrant=# select date '2012-01-01' + interval '-30' days;
        days
---------------------
 2011-12-31 23:59:30
(1 row)
{code}

Cleaning this stuff up would be really great.

> Make interval keyword optional while specifying DAY in interval arithmetic
> --------------------------------------------------------------------------
>
>                 Key: HIVE-13557
>                 URL: https://issues.apache.org/jira/browse/HIVE-13557
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Types
>            Reporter: Ashutosh Chauhan
>
> Currently we support expressions like: {code}
> WHERE SOLD_DATE BETWEEN ((DATE('2000-01-31'))  - INTERVAL '30' DAY) AND 
> DATE('2000-01-31')
> {code}
> We should support:
> {code}
> WHERE SOLD_DATE BETWEEN ((DATE('2000-01-31')) + (-30) DAY) AND 
> DATE('2000-01-31')
> {code}
>   



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to