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

Null comparison for greatest and least operator

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: UDF
    • Labels:
      None

      Description

      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 and https://dev.mysql.com/doc/refman/5.0/en/type-conversion.html.

      This can be demonstrated by the following mysql query:

      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)
      

      This is in contrast to Hive, where null are ignored in the comparisons.

      hive> select greatest(null, 1) from test;
      OK
      1
      

        Attachments

        1. HIVE-12082.2.patch
          45 kB
          Szehon Ho
        2. HIVE-12082.patch
          46 kB
          Szehon Ho

          Issue Links

            Activity

              People

              • Assignee:
                szehon Szehon Ho
                Reporter:
                szehon Szehon Ho
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: