hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Dere (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HIVE-9357) Create ADD_MONTHS UDF
Date Wed, 14 Jan 2015 02:39:34 GMT

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

Jason Dere commented on HIVE-9357:
----------------------------------

Not sure I agree with these last day of month semantics, at least when going from a shorter
month to a longer month. Take a look at the examples below for both MySQL and Postgres. We
might end up adding Interval type and I'd like the behavior to be consistent between that
and this udf.

{noformat}
mysql> select date_add(date '2011-01-31', interval 1 month);
+-----------------------------------------------+
| date_add(date '2011-01-31', interval 1 month) |
+-----------------------------------------------+
| 2011-02-28                                    |
+-----------------------------------------------+
1 row in set (0.00 sec)

mysql> select date_add(date '2011-02-28', interval 1 month);
+-----------------------------------------------+
| date_add(date '2011-02-28', interval 1 month) |
+-----------------------------------------------+
| 2011-03-28                                    |
+-----------------------------------------------+
1 row in set (0.00 sec)



postgres=# select date '2011-01-31' + interval '1 month';
      ?column?       
---------------------
 2011-02-28 00:00:00
(1 row)

postgres=# select date '2011-02-28' + interval '1 month' ;
      ?column?       
---------------------
 2011-03-28 00:00:00
(1 row)
{noformat}

> Create ADD_MONTHS UDF
> ---------------------
>
>                 Key: HIVE-9357
>                 URL: https://issues.apache.org/jira/browse/HIVE-9357
>             Project: Hive
>          Issue Type: Improvement
>          Components: UDF
>            Reporter: Alexander Pivovarov
>            Assignee: Alexander Pivovarov
>         Attachments: HIVE-9357.1.patch
>
>
> ADD_MONTHS adds a number of months to startdate: 
> add_months('2015-01-14', 1) = '2015-02-14'
> add_months('2015-01-31', 1) = '2015-02-28'
> add_months('2015-02-28', 2) = '2015-04-30'
> add_months('2015-02-28', 12) = '2016-02-29'



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

Mime
View raw message