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

Unexpected result when using MIN() on struct with NULL in first field

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 2.1.0
    • Component/s: Hive
    • Labels:
      None

      Description

      Using MIN() on struct with NULL in first field of a row yields NULL as result.

      Example:

      select min(a) FROM (select 1 as a union all select 2 as a union all select cast(null as int) as a) tmp;
      OK
      _c0
      1

      As expected. But if we wrap it in a struct:

      select min(a) FROM (select named_struct("field",1) as a union all select named_struct("field",2) as a union all select named_struct("field",cast(null as int)) as a) tmp;
      OK
      _c0
      NULL

      Using MAX() works as expected for structs.

        Attachments

        1. HIVE-12941.1.patch
          9 kB
          Yongzhi Chen
        2. HIVE-12941.2.patch
          9 kB
          Yongzhi Chen
        3. HIVE-12941.3.patch
          10 kB
          Yongzhi Chen

          Activity

            People

            • Assignee:
              ychena Yongzhi Chen
              Reporter:
              jan-erik.hedbom Jan-Erik Hedbom
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: