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

[jira] [Commented] (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=16729305#comment-16729305 ] 

Bridget Bevens commented on DRILL-3610:
---------------------------------------

Hi [~vvysotskyi]

 On this page: https://drill.apache.org/docs/date-time-functions-and-arithmetic/    

I added the following two sections:   

* [https://drill.apache.org/docs/date-time-functions-and-arithmetic/#timestampadd]
* [https://drill.apache.org/docs/date-time-functions-and-arithmetic/#timestampdiff]

For timestampadd, I did not include hour, minute, second, etc. time units because they did not work for me, as shown:

SELECT TIMESTAMPADD(MINUTE,1,'2003-01-02');

Error: SYSTEM ERROR: AssertionError: Conversion to relational algebra failed to preserve datatypes:

validated type:

RecordType(TIMESTAMP(3) NOT NULL EXPR$0) NOT NULL

converted type:

RecordType(TIMESTAMP(0) NOT NULL EXPR$0) NOT NULL

rel:

LogicalProject(EXPR$0=[+('2003-01-02', *(60000, 1))])

  LogicalValues(tuples=[[\{ 0 }]])

Please, refer to logs for more information.

 

Please review and let me know if I need to make any changes to the doc.

Thanks,
 Bridget

> 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-impacting, 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)