[
https://issues.apache.org/jira/browse/HIVE-9357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14276449#comment-14276449
]
Alexander Pivovarov commented on HIVE-9357:
-------------------------------------------
add_months function went from oracle
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions004.htm
I put several ADD_MONTHS examples below
{code}
select to_date('14-JAN-2014') from_date, 1 months, add_months('14-JAN-2014', 1)
res from dual union all
select to_date('31-JAN-2014') from_date, 1 months, add_months('31-JAN-2014', 1)
res from dual union all
select to_date('28-FEB-2014') from_date, -1 months, add_months('28-FEB-2014',
-1) res from dual union all
select to_date('28-FEB-2014') from_date, 2 months, add_months('28-FEB-2014', 2)
res from dual union all
select to_date('30-APR-2014') from_date, -2 months, add_months('30-APR-2014',
-2) res from dual union all
select to_date('28-FEB-2015') from_date, 12 months, add_months('28-FEB-2015',
12) res from dual union all
select to_date('29-FEB-2016') from_date, -12 months, add_months('29-FEB-2016',
-12) res from dual union all
select to_date('29-JAN-2016') from_date, 1 months, add_months('29-JAN-2016', 1)
res from dual union all
select to_date('29-FEB-2016') from_date, -1 months, add_months('29-FEB-2016',
-1) res from dual;
from_date months res
2014-01-14 1 2014-02-14
2014-01-31 1 2014-02-28
2014-02-28 -1 2014-01-31
2014-02-28 2 2014-04-30
2014-04-30 -2 2014-02-28
2015-02-28 12 2016-02-29
2016-02-29 -12 2015-02-28
2016-01-29 1 2016-02-29
2016-02-29 -1 2016-01-31
{code}
add_month function is used in many BI projects (especially in financial
applications (e.g. to determine 36 mo loan end date)).
>From my experience most of BI projects was implemented in Oracle.
Lots of BI projects are migrating to Hive now.
So, lots of projects depends on Oracle add_months function business logic.
as a separate activity existing hive udf date_add can be improved to be similar
to MySQL implementation (if smbd need it)
I belive add_months udf brings lots of business value to hive because many
companies want easier migration from oracle fo hive.
I think Oracle is used in most of enterprise big data companies.
> 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)