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

union all does not generate correct result for order by and limit

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

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.2.0
    • None
    • None

    Description

      Right now if we have
      select col from A
      union all
      select col from B [Operator]

      it is treated as

      (select col from A)
      union all
      (select col from B [Operator])

      Although it is correct for where, group by (having) join operators, it is not correct for order by and limit operators. They should be

      (select col from A
      union all
      select col from B) [order by, limit]

      For order by, we can refer to MySQL, Oracle, DB2

      mysql

      http://dev.mysql.com/doc/refman/5.1/en/union.html

      oracle

      https://docs.oracle.com/cd/E17952_01/refman-5.0-en/union.html

      ibm

      http://www-01.ibm.com/support/knowledgecenter/ssw_i5_54/sqlp/rbafykeyu.htm

      Attachments

        Issue Links

        Activity

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

          People

            pxiong Pengcheng Xiong Assign to me
            pxiong Pengcheng Xiong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment