hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Pivovarov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HIVE-10178) DateWritable incorrectly calculates daysSinceEpoch for negative Unix time
Date Wed, 01 Apr 2015 08:26:52 GMT

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

Alexander Pivovarov updated HIVE-10178:
---------------------------------------
    Attachment: HIVE-10178.02.patch

patch #02. - replaced Math.floor with ((millisUtc - 86399999) / MILLIS_PER_DAY) to avoid conversion
to double

All the following tests return 1966-01-01
{code}
select cast(cast('1966-01-01 00:00:00.000000001' as timestamp) as date);
select cast(cast('1966-01-01 00:00:00.000001' as timestamp) as date);
select cast(cast('1966-01-01 00:00:00.001' as timestamp) as date);
select cast(cast('1966-01-01 00:00:01' as timestamp) as date);
select cast(cast('1966-01-01 10:00:01' as timestamp) as date);
select cast(cast('1966-01-01 23:59:59' as timestamp) as date);
select cast(cast('1966-01-01 23:59:59.999' as timestamp) as date);
select cast(cast('1966-01-01 23:59:59.999999' as timestamp) as date);
select cast(cast('1966-01-01 23:59:59.999999999' as timestamp) as date);
{code}

> DateWritable incorrectly calculates daysSinceEpoch for negative Unix time
> -------------------------------------------------------------------------
>
>                 Key: HIVE-10178
>                 URL: https://issues.apache.org/jira/browse/HIVE-10178
>             Project: Hive
>          Issue Type: Bug
>          Components: Types
>            Reporter: Alexander Pivovarov
>            Assignee: Alexander Pivovarov
>         Attachments: HIVE-10178.01.patch, HIVE-10178.02.patch
>
>
> For example:
> {code}
> select cast(cast('1966-01-01 00:00:01' as timestamp) as date);
> 1966-01-02
> {code}
> Another example:
> {code}
> select last_day(cast('1966-01-31 00:00:01' as timestamp));
> OK
> 1966-02-28
> {code}
> more details:
> Date: 1966-01-01 00:00:01
> unix time UTC: -126230399
> daysSinceEpoch=−126230399000 / 86400000 = -1460.999988
> int daysSinceEpoch = -1460
> DateWritable having daysSinceEpoch=-1460 is 1966-01-02
> daysSinceEpoch should be -1461 instead  (1966-01-01)



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

Mime
View raw message