Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-5655

Hive incorrecly handles divide-by-zero case

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.10.0, 0.11.0, 0.12.0
    • 0.13.0
    • Types
    • None
    • The behaviour needs to be documented.

    Description

      Unlike other databases, Hive currently has only one mode (default mode) regarding error handling, in which NULL value is returned. However, in case of divide-by-zero, Hive demonstrated a different behavior.

      hive> select 5/0 from tmp2 limit 1;
      Total MapReduce jobs = 1
      ...
      Total MapReduce CPU Time Spent: 860 msec
      OK
      Infinity
      

      The correct behaviour should be Hive returning NULL instead in order to be consistent w.r.t error handling. (BTW, the same situation is handled corrected for decimal type.)

      MySQL has server modes control the behaviour. By default, NULL is returned. For instance,

      mysql> select 3/0 from dual;
      +------+
      | 3/0  |
      +------+
      | NULL |
      +------+
      1 row in set (0.00 sec)
      

      Attachments

        1. HIVE-5655.1.patch
          7 kB
          Xuefu Zhang
        2. HIVE-5655.2.patch
          16 kB
          Xuefu Zhang
        3. HIVE-5655.3.patch
          16 kB
          Xuefu Zhang
        4. HIVE-5655.patch
          7 kB
          Xuefu Zhang

        Issue Links

          Activity

            People

              xuefuz Xuefu Zhang
              xuefuz Xuefu Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: