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

Nested ORDER BY produces incorrect result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 0.9.0
    • None
    • Query Processor, SQL, UDF
    • None
    • Red Hat Linux VM with Hive 0.9 and Hadoop 2.0

    Description

      Nested ORDER BY clause doesn't honor the outer one in specific case.

      The below query produces result which honors only the inner ORDER BY clause. (it produces only 1 MapRed job)

      SELECT alias.b0 as d0, alias.b1 as d1
      FROM
          (SELECT test.a0 as b0, test.a1 as b1 
          FROM test
          ORDER BY b1 ASC, b0 DESC) alias    
      ORDER BY d0 ASC, d1 DESC;
      
      

      On the other hand the query below honors the outer ORDER BY clause which produces the correct result. (it produces 2 MapRed jobs)

      SELECT alias.b0 as d0, alias.b1 as d1
      FROM
          (SELECT test.a0 as b0, test.a1 as b1 
          FROM test
          ORDER BY b1 ASC, b0 DESC) alias    
      ORDER BY d0 DESC, d1 DESC;
      
      

      Any other combination of nested ORDER BY clauses does produce the correct result.
      Please see attachments for query, schema and Hive Commands for reprocase.

      Attachments

        1. Hive_Command_Script.txt
          0.2 kB
          Mihir Kulkarni
        2. HiveQuery.txt
          0.8 kB
          Mihir Kulkarni
        3. Test_Data.txt
          0.1 kB
          Mihir Kulkarni

        Activity

          People

            Unassigned Unassigned
            mihirk Mihir Kulkarni
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: