You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Sergey Nuyanzin (JIRA)" <ji...@apache.org> on 2018/06/14 09:45:00 UTC

[jira] [Commented] (CALCITE-2281) TIMESTAMPADD(MICROSECOND, ...) returns incorrect results

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

Sergey Nuyanzin commented on CALCITE-2281:
------------------------------------------

currently faced with another issue relating to timestampadd (issue name is very generic => post it here)
{code}    tester.checkScalar(
        "timestampadd(MICROSECOND, 2000000, timestamp '2016-02-24 12:42:25')",
        "2016-02-24 12:42:27",
        "TIMESTAMP(0) NOT NULL");{code} fails like {noformat}java.lang.AssertionError: 
Expected :[2016-02-24 12:42:27]
Actual   :[2016-02-24 12:42:25]{noformat}

Unfortunately the provided patch does not help with any of issues. As far as I understand the issue with precision is common for both timestampadd and timestampdiff - not clear for me how to fix, may be later will deep dive.

At the same time for my issue I have a fix here https://github.com/apache/calcite/compare/master...snuyanzin:CALCITE_2281

> TIMESTAMPADD(MICROSECOND, ...) returns incorrect results
> --------------------------------------------------------
>
>                 Key: CALCITE-2281
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2281
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Sudheesh Katkam
>            Assignee: Julian Hyde
>            Priority: Major
>         Attachments: CALCITE-2281.patch.txt
>
>
> Add this test to {{SqlOperatorBaseTest#testTimestampAdd}} :
> {code:java}
> tester.checkScalar(
>     "timestampadd(MICROSECOND, 2, timestamp '2016-02-24 12:42:25.000000')",
>     "2016-02-24 12:42:25.000002",
>     "TIMESTAMP(6) NOT NULL");{code}
> {{[SqlTimestampAddFunction|https://github.com/apache/calcite/blob/8327e674e7f0a768d124fa37fd75cda4b8a35bb6/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java#L68]}} has incorrect precision for MILLISECOND and MICROSECOND. Note that the parser does not allow for MILLISECOND as a time unit.



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