From 0bb66ef3270d643e1fb6c971e26ebfa3302ca4ed Mon Sep 17 00:00:00 2001 From: Victor Bittorf Date: Tue, 15 Apr 2014 13:16:32 -0700 Subject: [PATCH] Adding aliases ADD_MONTHS and SUB_MONTHS This is a request for consistency with oracle. Change-Id: I463a66694a068cd773532d8f6f853a4b089b918a Reviewed-on: http://gerrit.ent.cloudera.com:8080/2400 Reviewed-by: Victor Bittorf Tested-by: jenkins (cherry picked from commit 1f0b643789596f96c54580b8c5262fada4dfc958) Reviewed-on: http://gerrit.ent.cloudera.com:8080/2502 --- common/function-registry/impala_functions.py | 4 ++-- .../functional-query/queries/QueryTest/exprs.test | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/function-registry/impala_functions.py b/common/function-registry/impala_functions.py index a498fa60a..094e31b88 100755 --- a/common/function-registry/impala_functions.py +++ b/common/function-registry/impala_functions.py @@ -284,9 +284,9 @@ functions = [ '_ZN6impala18TimestampFunctions10DateAddSubILb0EiN5boost9date_time14years_durationINS2_9gregorian21greg_durations_configEEEEEPvPNS_4ExprEPNS_8TupleRowE'], [['years_sub'], 'TIMESTAMP', ['TIMESTAMP', 'BIGINT'], '_ZN6impala18TimestampFunctions10DateAddSubILb0ElN5boost9date_time14years_durationINS2_9gregorian21greg_durations_configEEEEEPvPNS_4ExprEPNS_8TupleRowE'], - [['months_add'], 'TIMESTAMP', ['TIMESTAMP', 'INT'], + [['months_add', 'add_months'], 'TIMESTAMP', ['TIMESTAMP', 'INT'], '_ZN6impala18TimestampFunctions10DateAddSubILb1EiN5boost9date_time15months_durationINS2_9gregorian21greg_durations_configEEEEEPvPNS_4ExprEPNS_8TupleRowE'], - [['months_add'], 'TIMESTAMP', ['TIMESTAMP', 'BIGINT'], + [['months_add', 'add_months'], 'TIMESTAMP', ['TIMESTAMP', 'BIGINT'], '_ZN6impala18TimestampFunctions10DateAddSubILb1ElN5boost9date_time15months_durationINS2_9gregorian21greg_durations_configEEEEEPvPNS_4ExprEPNS_8TupleRowE'], [['months_sub'], 'TIMESTAMP', ['TIMESTAMP', 'INT'], '_ZN6impala18TimestampFunctions10DateAddSubILb0EiN5boost9date_time15months_durationINS2_9gregorian21greg_durations_configEEEEEPvPNS_4ExprEPNS_8TupleRowE'], diff --git a/testdata/workloads/functional-query/queries/QueryTest/exprs.test b/testdata/workloads/functional-query/queries/QueryTest/exprs.test index aebce34a5..cfc6238da 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/exprs.test +++ b/testdata/workloads/functional-query/queries/QueryTest/exprs.test @@ -1,5 +1,13 @@ ==== ---- QUERY +# check that add_months alias is working +select ADD_MONTHS(cast('2013-02-18 16:46:00.01' as timestamp), 1) +---- TYPES +timestamp +---- RESULTS +2013-03-18 16:46:00.010000000 +==== +---- QUERY # test extract with non-constant field name select b.unit, extract(a.ts, b.unit) from (values(cast('2013-02-18 16:46:00.01' as timestamp) ts)) a