Krystal created DRILL-4610:
------------------------------
Summary: Inconsistent return type b/w date_add & date_sub
functions w/ date & interval
Key: DRILL-4610
URL: https://issues.apache.org/jira/browse/DRILL-4610
Project: Apache Drill
Issue Type: Bug
Components: Functions - Drill
Reporter: Krystal
git.commit.id.abbrev=e4725ea
date_add(date, interval) function returns a timestamp while date_sub(date,
interval) function returns a date. Some examples are:
select date_add(to_date('2017-02-01', 'YYYY-MM-dd'), interval '1' MONTH) from
test_tbl limit 1;
+------------------------+
| EXPR$0 |
+------------------------+
| 2017-03-01 00:00:00.0 |
+------------------------+
select date_sub(create_date, interval '1' MONTH) from test_tbl where limit 1;
+-------------+
| EXPR$0 |
+-------------+
| 2017-03-06 |
+-------------+
select date_add(to_date('2017-02-01', 'YYYY-MM-dd'), interval '1 10:20:30' DAY
to second) from test_tbl limit 1;
+------------------------+
| EXPR$0 |
+------------------------+
| 2017-02-02 10:20:30.0 |
+------------------------+
select date_sub(create_date, interval '1 10:20:30' DAY to second) from
voter_parquet where voter_id=10;
+-------------+
| EXPR$0 |
+-------------+
| 2017-04-04 |
+-------------+
select date_sub(to_date('2017-02-01', 'YYYY-MM-dd'), interval '1 10:20:30' DAY
to second) from test_tbl limit 1;
+-------------+
| EXPR$0 |
+-------------+
| 2017-01-30 |
+-------------+
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)