calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remus Rusanu (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CALCITE-1664) CAST('<string>' as TIMESTAMP) adds part of sub-second fraction to the value
Date Mon, 27 Feb 2017 13:39:46 GMT
Remus Rusanu created CALCITE-1664:
-------------------------------------

             Summary: CAST('<string>' as TIMESTAMP) adds part of sub-second fraction
to the value
                 Key: CALCITE-1664
                 URL: https://issues.apache.org/jira/browse/CALCITE-1664
             Project: Calcite
          Issue Type: Bug
            Reporter: Remus Rusanu
            Assignee: Julian Hyde


{noformat}
select   
  TIMESTAMP '2016-02-26 19:06:00',
  CAST('2016-02-26 19:06:00' as TIMESTAMP);
 +---------------------+---------------------+
 | EXPR$0              | EXPR$1              |
 +---------------------+---------------------+
 | 2016-02-26 19:06:00 | 2016-02-26 19:06:00 |
 +---------------------+---------------------+
!ok

select
  TIMESTAMP '2016-02-26 19:06:00.1',
  CAST('2016-02-26 19:06:00.1' as TIMESTAMP),
  TIMESTAMPDIFF(SECOND,
    TIMESTAMP '2016-02-26 19:06:00.1',
    CAST('2016-02-26 19:06:00.1' as TIMESTAMP));
 +---------------------+---------------------+--------+
 | EXPR$0              | EXPR$1              | EXPR$2 |
 +---------------------+---------------------+--------+
 | 2016-02-26 19:06:00 | 2016-02-26 19:06:00 |      0 |
 +---------------------+---------------------+--------+
!ok

select
  TIMESTAMP '2016-02-26 19:06:00.123456',
  CAST('2016-02-26 19:06:00.123456' as TIMESTAMP),
  TIMESTAMPDIFF(SECOND,
    TIMESTAMP '2016-02-26 19:06:00.123456',
    CAST('2016-02-26 19:06:00.123456' as TIMESTAMP));
 +---------------------+---------------------+--------+
 | EXPR$0              | EXPR$1              | EXPR$2 |
 +---------------------+---------------------+--------+
 | 2016-02-26 19:06:00 | 2016-02-26 19:08:03 |    123 |
 +---------------------+---------------------+--------+
!ok

select
  TIMESTAMP '2016-02-26 19:06:00.12345678',
  CAST('2016-02-26 19:06:00.12345678' as TIMESTAMP),
  TIMESTAMPDIFF(SECOND,
    TIMESTAMP '2016-02-26 19:06:00.123456789',
    CAST('2016-02-26 19:06:00.123456789' as TIMESTAMP));
 +---------------------+---------------------+--------+
 | EXPR$0              | EXPR$1              | EXPR$2 |
 +---------------------+---------------------+--------+
 | 2016-02-26 19:06:00 | 2016-02-26 22:31:46 | 123456 |
 +---------------------+---------------------+--------+
!ok
{noformat}

Note how {{TIMESTAMP <string>}} parses the value correctly (not sure if the sub-second
fraction is parsed though) but {{CAST}} adds part of the sub-second fraction as a seconds
to the value.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message