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

Fix column projection for union all queries with multiple aliases

Log workAgile BoardRank to TopRank to BottomBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Given two tables:

      create table source1 (dt string, d1 int, d2 int) stored as orc;
      create table source2 (dt string, d1 int, d2 int) stored as orc;
      insert into source1 values ('20211107', 1, 2);
      insert into source2 values ('20211108', 11, 22);

      If you run this query with UNION ALL, the key column will be missing from the output:

      select explode(map('D219', D219
      ,'D220', D220)) as (key, value) from (
         {{select '20211107' as date_key
      ,1 as D219
      ,2 as D220
      ) t}}
      union all
      select explode(map('D221', D221
      ,'D222', D222)) as (key, value)
      from (}}
        {{select '20211107' as date_key
      ,1 as D221
      ,2 as D222
      ) t

      Result:

      1
      2
      11
      22

       Correct result should be:

      D219 1
      D220 2
      D221 11
      D222 22

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Marton Bod Marton Bod Assign to me
            Marton Bod Marton Bod
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment