You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Gopal V (JIRA)" <ji...@apache.org> on 2017/12/20 00:15:00 UTC

[jira] [Comment Edited] (HIVE-18304) datediff() UDF returns a wrong result when dealing with a (date, string) input

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

Gopal V edited comment on HIVE-18304 at 12/20/17 12:14 AM:
-----------------------------------------------------------

[~hengyu.dai]: please post the timezone(s) in which this gives an error? 

The reason Timestamp and Date disagrees is often due to timestamp adjustments.

{code}
for '2012-01-01' we will get 2012-01-01T08:00:00.000+0800
{code}

Looks like it does +8 for one?


was (Author: gopalv):
[~hengyu.dai]: please post the timezone in which this gives an error? The reason Timestamp and Date disagrees is often due to timestamp adjustments.

> datediff() UDF returns a wrong result when dealing with a (date, string) input
> ------------------------------------------------------------------------------
>
>                 Key: HIVE-18304
>                 URL: https://issues.apache.org/jira/browse/HIVE-18304
>             Project: Hive
>          Issue Type: Bug
>          Components: UDF
>            Reporter: Hengyu Dai
>            Assignee: Hengyu Dai
>            Priority: Minor
>         Attachments: 0001.patch
>
>
> for date type argument, datediff() use DateConverter to convert input to a java Date object, 
> for example, a '2017-12-18' will get 2017-12-18T00:00:00.000+0800
> for string type argument, datediff() use TextConverter to convert a string to date,
> for '2012-01-01' we will get 2012-01-01T08:00:00.000+0800
> now, datediff() will return a number less than the real date diff
> we should use TextConverter to deal with date input too.
> reproduce:
> {code:java}
> select datediff(cast('2017-12-18' as date), '2012-01-01'); --2177
> select datediff('2017-12-18', '2012-01-01'); --2178
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)