You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Arina Ielchiieva (JIRA)" <ji...@apache.org> on 2016/03/10 13:53:40 UTC

[jira] [Reopened] (CALCITE-1124) Add support for timestampadd / timestampdiff functions

     [ https://issues.apache.org/jira/browse/CALCITE-1124?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arina Ielchiieva reopened CALCITE-1124:
---------------------------------------

SqlOperatorBaseTest.testTimestampDiff has unexpected results for timestampdiff function.
For example, when you calculate timestampdiff(interval, smaller value, greater value) expected result is positive difference, if timestampdiff(interval, greater value, smaller value) - negative.

Queries I have executed in MySql:

{code:sql}
select timestampdiff(HOUR, str_to_date('2016-02-24 12:42:25.000', '%Y-%m-%d %H:%i:%s.%f'), str_to_date('2016-02-24 15:42:25.000', '%Y-%m-%d %H:%i:%s.%f')) as ACTUAL;
-- 3
select timestampdiff(MICROSECOND, str_to_date('2016-02-24 12:42:25.000', '%Y-%m-%d %H:%i:%s.%f'), str_to_date('2016-02-24 12:42:20.000', '%Y-%m-%d %H:%i:%s.%f')) as ACTUAL;
-- -5000000
{code}



> Add support for timestampadd / timestampdiff functions
> ------------------------------------------------------
>
>                 Key: CALCITE-1124
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1124
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: next
>            Reporter: Arina Ielchiieva
>            Assignee: Julian Hyde
>              Labels: dialect
>             Fix For: 1.7.0
>
>
> When calling timestampadd / timestampdiff with first parameter:
> (SQL_TSI_)MICROSECOND ((SQL_TSI_)FRAC_SECOND (deprecated but we can leave for older versions compatibility)), (SQL_TSI_)SECOND, (SQL_TSI_)MINUTE, (SQL_TSI_)HOUR, (SQL_TSI_)DAY, (SQL_TSI_)WEEK, (SQL_TSI_)MONTH, (SQL_TSI_)QUARTER, (SQL_TSI_)YEAR
> (ex: timestampadd(second, 1, current_datetime), calcite throws an error:
> Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered "( SECOND" at line 1, column 25.
> Was expecting one of:
>     "(" "*" ...
>     "(" ")" ...
>     "(" "WITH" ...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)