hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dudu Markovitz (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (HIVE-12082) Null comparison for greatest and least operator
Date Thu, 25 May 2017 10:58:04 GMT

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

Dudu Markovitz edited comment on HIVE-12082 at 5/25/17 10:57 AM:
-----------------------------------------------------------------

[~leftylev], you were actually right in the first place. 
The functions _least_ and _greatest_ are not (just) mathematical functions, they work for
every primitive type and therefore should be documented in the conditional section.

e.g., 

{code}
select greatest ('goodbye','yellow','brick','road');                       -- yellow
select least    (date '2017-03-25',date '2017-01-17',date '2017-01-02');   -- 2017-01-02
{code}



was (Author: dmarkovitz):
[~leftylev]], you were actually right in the first place. 
The functions _least_ and _greatest_ are not (just) mathematical functions, they work for
every primitive type and therefore should be documented in the conditional section.

e.g., 

{code}
select greatest ('goodbye','yellow','brick','road');                       -- yellow
select least    (date '2017-03-25',date '2017-01-17',date '2017-01-02');   -- 2017-01-02
{code}


> Null comparison for greatest and least operator
> -----------------------------------------------
>
>                 Key: HIVE-12082
>                 URL: https://issues.apache.org/jira/browse/HIVE-12082
>             Project: Hive
>          Issue Type: Bug
>          Components: UDF
>            Reporter: Szehon Ho
>            Assignee: Szehon Ho
>             Fix For: 2.0.0
>
>         Attachments: HIVE-12082.2.patch, HIVE-12082.patch
>
>
> In mysql comparisons if any of the entries are null, then the result is null.
> [https://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html|https://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html]
and [https://dev.mysql.com/doc/refman/5.0/en/type-conversion.html|https://dev.mysql.com/doc/refman/5.0/en/type-conversion.html].
> This can be demonstrated by the following mysql query:
> {noformat}
> mysql> select greatest(1, null) from test;
> +-------------------+
> | greatest(1, null) |
> +-------------------+
> |              NULL |
> +-------------------+
> 1 row in set (0.00 sec)
> mysql> select greatest(-1, null) from test;
> +--------------------+
> | greatest(-1, null) |
> +--------------------+
> |               NULL |
> +--------------------+
> 1 row in set (0.00 sec)
> {noformat}
> This is in contrast to Hive, where null are ignored in the comparisons.
> {noformat}
> hive> select greatest(null, 1) from test;
> OK
> 1
> {noformat}



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

Mime
View raw message