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

Getting error Failed rule: 'orderByClause clusterByClause distributeByClause sortByClause limitClause can only be applied to the whole union.' in subquery

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      The error comes in the following query:

      SELECT *
      FROM
        (SELECT *
         FROM srcpart a
         WHERE a.ds = '2008-04-08'
           AND a.hr = '11'
         ORDER BY a.key LIMIT 5
         UNION ALL
         SELECT *
         FROM srcpart b
         WHERE b.ds = '2008-04-08'
           AND b.hr = '14'
         ORDER BY b.key LIMIT 5) subq
      ORDER BY KEY LIMIT 5
      

      But the following query works:

      SELECT *
      FROM
        (SELECT *
         FROM
           (SELECT *
            FROM srcpart a
            WHERE a.ds = '2008-04-08'
              AND a.hr = '11'
            ORDER BY a.key LIMIT 5) pa
         UNION ALL SELECT *
         FROM
           (SELECT *
            FROM srcpart b
            WHERE b.ds = '2008-04-08'
              AND b.hr = '14'
            ORDER BY b.key LIMIT 5) pb) subq
      ORDER BY KEY LIMIT 5
      

      The queries are logically identical, the query that's rejected has dummy select * clauses around the sub-queries.

      Attachments

        Activity

          People

            Unassigned Unassigned
            prongs Rajat Khandelwal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: