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

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

Log workAgile BoardRank to TopRank to BottomVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

          $i18n.getText('security.level.explanation', $currentSelection) Viewable by All Users
          Cancel

            People

            • Assignee:
              ychena Yongzhi Chen Assign to me
              Reporter:
              jan-erik.hedbom Jan-Erik Hedbom

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment