Hive
  1. Hive
  2. HIVE-774

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.4.0, 0.5.0
    • Fix Version/s: 0.4.0, 0.5.0
    • Component/s: None
    • Labels:
      None
    • Hadoop Flags:
      Incompatible change, Reviewed
    • Release Note:
      HIVE-774. Fix the behavior of / and add DIV. (Ning Zhang via zshao)

      Description

      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.

      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)
      

        Issue Links

          Activity

            People

            • Assignee:
              Ning Zhang
              Reporter:
              Zheng Shao
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development