You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Volodymyr Vysotskyi (JIRA)" <ji...@apache.org> on 2018/12/27 08:20:00 UTC

[jira] [Comment Edited] (DRILL-3610) TimestampAdd/Diff (SQL_TSI_) functions

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

Volodymyr Vysotskyi edited comment on DRILL-3610 at 12/27/18 8:19 AM:
----------------------------------------------------------------------

Hi, [~bbevens], thanks for adding the docs!
There is a mistake in the queries for {{TIMESTAMPADD}}: this UDF should accept not varchar values as the last argument, but date, time or timestamp values.

So the next query works correctly:
{code:sql}
SELECT TIMESTAMPADD(MINUTE,1,date '2003-01-02');
{code}
{noformat}
+------------------------+
|         EXPR$0         |
+------------------------+
| 2003-01-02 00:01:00.0  |
+------------------------+
1 row selected (1.066 seconds)
{noformat}
Could you please modify docs to reflect that for both {{TIMESTAMPADD}} and {{TIMESTAMPDIFF}} UDFs?


was (Author: vvysotskyi):
Hi, [~bbevens], thanks for adding the docs!
There is a mistake in the queries for {{TIMESTAMPADD}}: this UDF should accept not varchar values as the last argument, but date, time or timestamp values.

So the next query works correctly:
{code:sql}
SELECT TIMESTAMPADD(MINUTE,1,date '2003-01-02');
{code}
{noformat}
+------------------------+
|         EXPR$0         |
+------------------------+
| 2003-01-02 00:01:00.0  |
+------------------------+
1 row selected (1.066 seconds)
{noformat}
Could you please modify docs to reflect that?

> TimestampAdd/Diff (SQL_TSI_) functions
> --------------------------------------
>
>                 Key: DRILL-3610
>                 URL: https://issues.apache.org/jira/browse/DRILL-3610
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Functions - Drill
>            Reporter: Andries Engelbrecht
>            Assignee: Volodymyr Vysotskyi
>            Priority: Major
>              Labels: doc-complete, ready-to-commit
>             Fix For: 1.15.0
>
>
> Add TimestampAdd and TimestampDiff (SQL_TSI) functions for year, quarter, month, week, day, hour, minute, second.
> Examples
> SELECT CAST(TIMESTAMPADD(SQL_TSI_QUARTER,1,Date('2013-03-31'), SQL_DATE) AS `column_quarter`
> FROM `table_in`
> HAVING (COUNT(1) > 0)
> SELECT `table_in`.`datetime` AS `column1`,
>   `table`.`Key` AS `column_Key`,
>   TIMESTAMPDIFF(SQL_TSI_MINUTE,to_timestamp('2004-07-04', 'yyyy-MM-dd'),`table_in`.`datetime`) AS `sum_datediff_minute`
> FROM `calcs`



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)