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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0
    • 2.1.0
    • Hive
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: