You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Zheng Shao (JIRA)" <ji...@apache.org> on 2009/08/20 03:03:15 UTC

[jira] Created: (HIVE-774) Fix the behavior of "/" and add "DIV"

Fix the behavior of "/" and add "DIV"
-------------------------------------

                 Key: HIVE-774
                 URL: https://issues.apache.org/jira/browse/HIVE-774
             Project: Hadoop Hive
          Issue Type: Bug
    Affects Versions: 0.4.0, 0.5.0
            Reporter: Zheng Shao


In hive, "select 3/2" will return 1 while MySQL returns 1.5.

See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.

{code}
mysql> select 3/2;
+--------+
| 3/2    |
+--------+
| 1.5000 |
+--------+
1 row in set (0.00 sec)

mysql> select 3 div 2;
+---------+
| 3 div 2 |
+---------+
|       1 |
+---------+
1 row in set (0.00 sec)

mysql> select -3 div 2;
+----------+
| -3 div 2 |
+----------+
|       -1 |
+----------+
1 row in set (0.00 sec)

mysql> select -3 div -2;
+-----------+
| -3 div -2 |
+-----------+
|         1 |
+-----------+
1 row in set (0.00 sec)

mysql> select 3 div -2;
+----------+
| 3 div -2 |
+----------+
|       -1 |
+----------+
1 row in set (0.00 sec)
{code}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-774) Fix the behavior of "/" and add "DIV"

Posted by "Edward Capriolo (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12745448#action_12745448 ] 

Edward Capriolo commented on HIVE-774:
--------------------------------------

I have not had to deal with many hive precision issues, also I do not really have an opinion on how things should work. But I think we might want to consider deferring to how Java does things rather then how MySQL handles things. 
On one had its nice to handle things like the mysql reference says to handle things. Of course the mysql reference will have from subtle to not so subtle changes between versions. 

While I think it is great to have all the UDF's that mysql may have, I don't think we should always defer to doing something as mysql would, unless mysql is doing it to match some larger SQL standard.

> Fix the behavior of "/" and add "DIV"
> -------------------------------------
>
>                 Key: HIVE-774
>                 URL: https://issues.apache.org/jira/browse/HIVE-774
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Zheng Shao
>            Assignee: Ning Zhang
>             Fix For: 0.4.0, 0.5.0
>
>         Attachments: hive-774.patch
>
>
> In hive, "select 3/2" will return 1 while MySQL returns 1.5.
> See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.
> {code}
> mysql> select 3/2;
> +--------+
> | 3/2    |
> +--------+
> | 1.5000 |
> +--------+
> 1 row in set (0.00 sec)
> mysql> select 3 div 2;
> +---------+
> | 3 div 2 |
> +---------+
> |       1 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select -3 div 2;
> +----------+
> | -3 div 2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> mysql> select -3 div -2;
> +-----------+
> | -3 div -2 |
> +-----------+
> |         1 |
> +-----------+
> 1 row in set (0.00 sec)
> mysql> select 3 div -2;
> +----------+
> | 3 div -2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HIVE-774) Fix the behavior of "/" and add "DIV"

Posted by "Ning Zhang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ning Zhang updated HIVE-774:
----------------------------

    Attachment: hive-774.patch

> Fix the behavior of "/" and add "DIV"
> -------------------------------------
>
>                 Key: HIVE-774
>                 URL: https://issues.apache.org/jira/browse/HIVE-774
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Zheng Shao
>            Assignee: Ning Zhang
>         Attachments: hive-774.patch
>
>
> In hive, "select 3/2" will return 1 while MySQL returns 1.5.
> See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.
> {code}
> mysql> select 3/2;
> +--------+
> | 3/2    |
> +--------+
> | 1.5000 |
> +--------+
> 1 row in set (0.00 sec)
> mysql> select 3 div 2;
> +---------+
> | 3 div 2 |
> +---------+
> |       1 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select -3 div 2;
> +----------+
> | -3 div 2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> mysql> select -3 div -2;
> +-----------+
> | -3 div -2 |
> +-----------+
> |         1 |
> +-----------+
> 1 row in set (0.00 sec)
> mysql> select 3 div -2;
> +----------+
> | 3 div -2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HIVE-774) Fix the behavior of "/" and add "DIV"

Posted by "Zheng Shao (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zheng Shao reassigned HIVE-774:
-------------------------------

    Assignee: Ning Zhang

> Fix the behavior of "/" and add "DIV"
> -------------------------------------
>
>                 Key: HIVE-774
>                 URL: https://issues.apache.org/jira/browse/HIVE-774
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Zheng Shao
>            Assignee: Ning Zhang
>
> In hive, "select 3/2" will return 1 while MySQL returns 1.5.
> See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.
> {code}
> mysql> select 3/2;
> +--------+
> | 3/2    |
> +--------+
> | 1.5000 |
> +--------+
> 1 row in set (0.00 sec)
> mysql> select 3 div 2;
> +---------+
> | 3 div 2 |
> +---------+
> |       1 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select -3 div 2;
> +----------+
> | -3 div 2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> mysql> select -3 div -2;
> +-----------+
> | -3 div -2 |
> +-----------+
> |         1 |
> +-----------+
> 1 row in set (0.00 sec)
> mysql> select 3 div -2;
> +----------+
> | 3 div -2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HIVE-774) Fix the behavior of "/" and add "DIV"

Posted by "Ning Zhang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HIVE-774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12745492#action_12745492 ] 

Ning Zhang commented on HIVE-774:
---------------------------------

It's a good point Edward. In fact SQL does not standardize numeric operators such as '/'. Different DBMS vendors may adopt different semantics (e.g, MySQL vs. PostgresSQL). I agree we should be carefully define and document the semantics of these operators since they could be used extensively in analytic queries. 

> Fix the behavior of "/" and add "DIV"
> -------------------------------------
>
>                 Key: HIVE-774
>                 URL: https://issues.apache.org/jira/browse/HIVE-774
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Zheng Shao
>            Assignee: Ning Zhang
>             Fix For: 0.4.0, 0.5.0
>
>         Attachments: hive-774.patch
>
>
> In hive, "select 3/2" will return 1 while MySQL returns 1.5.
> See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.
> {code}
> mysql> select 3/2;
> +--------+
> | 3/2    |
> +--------+
> | 1.5000 |
> +--------+
> 1 row in set (0.00 sec)
> mysql> select 3 div 2;
> +---------+
> | 3 div 2 |
> +---------+
> |       1 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select -3 div 2;
> +----------+
> | -3 div 2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> mysql> select -3 div -2;
> +-----------+
> | -3 div -2 |
> +-----------+
> |         1 |
> +-----------+
> 1 row in set (0.00 sec)
> mysql> select 3 div -2;
> +----------+
> | 3 div -2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HIVE-774) Fix the behavior of "/" and add "DIV"

Posted by "Zheng Shao (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HIVE-774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zheng Shao resolved HIVE-774.
-----------------------------

       Resolution: Fixed
    Fix Version/s: 0.5.0
                   0.4.0
     Release Note: HIVE-774. Fix the behavior of / and add DIV. (Ning Zhang via zshao)
     Hadoop Flags: [Incompatible change, Reviewed]  (was: [Incompatible change])

Committed. Thanks Ning!

> Fix the behavior of "/" and add "DIV"
> -------------------------------------
>
>                 Key: HIVE-774
>                 URL: https://issues.apache.org/jira/browse/HIVE-774
>             Project: Hadoop Hive
>          Issue Type: Bug
>    Affects Versions: 0.4.0, 0.5.0
>            Reporter: Zheng Shao
>            Assignee: Ning Zhang
>             Fix For: 0.4.0, 0.5.0
>
>         Attachments: hive-774.patch
>
>
> In hive, "select 3/2" will return 1 while MySQL returns 1.5.
> See http://dev.mysql.com/doc/refman/5.0/en/arithmetic-functions.html#operator_div for details.
> {code}
> mysql> select 3/2;
> +--------+
> | 3/2    |
> +--------+
> | 1.5000 |
> +--------+
> 1 row in set (0.00 sec)
> mysql> select 3 div 2;
> +---------+
> | 3 div 2 |
> +---------+
> |       1 |
> +---------+
> 1 row in set (0.00 sec)
> mysql> select -3 div 2;
> +----------+
> | -3 div 2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> mysql> select -3 div -2;
> +-----------+
> | -3 div -2 |
> +-----------+
> |         1 |
> +-----------+
> 1 row in set (0.00 sec)
> mysql> select 3 div -2;
> +----------+
> | 3 div -2 |
> +----------+
> |       -1 |
> +----------+
> 1 row in set (0.00 sec)
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.