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

ORDER BY colName DESC does not honour 'hive.default.nulls.last' property in absence of NULLS_LAST/FIRST

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • 4.0.0
    • None
    • Parser

    Description

      Consider the following table and data:

      create table test1
      (
        a string,
        b timestamp,
        c timestamp
      );
      
      INSERT INTO TABLE test1 VALUES
      ('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
      ('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
      ('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
      ('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
      ('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
      ('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
      ('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
      ('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
      ('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
      ('John Doe', '1987-05-10 00:00:00.0', null);

      Consider also the following query:

      SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC) FROM test1; 
      

      The output is:

      John Doe	10/05/1990 00:00	10/01/2022 00:00	1
      John Doe	10/05/1990 00:00	10/12/2021 00:00	2
      John Doe	10/05/1990 00:00	10/11/2021 00:00	3
      John Doe	10/05/1990 00:00	10/10/2021 00:00	4
      John Doe	10/05/1990 00:00	10/09/2021 00:00	5
      John Doe	10/05/1987 00:00	NULL 	                1
      John Doe	10/05/1987 00:00	10/01/2022 00:00	2
      John Doe	10/05/1987 00:00	10/12/2021 00:00	3
      John Doe	10/05/1987 00:00	10/11/2021 00:00	4
      John Doe	10/05/1987 00:00	10/10/2021 00:00	5

      While the expected output should be:

      John Doe	10/05/1990 00:00	10/01/2022 00:00	1
      John Doe	10/05/1990 00:00	10/12/2021 00:00	2
      John Doe	10/05/1990 00:00	10/11/2021 00:00	3
      John Doe	10/05/1990 00:00	10/10/2021 00:00	4
      John Doe	10/05/1990 00:00	10/09/2021 00:00	5
      John Doe	10/05/1987 00:00	10/01/2022 00:00	1
      John Doe	10/05/1987 00:00	10/12/2021 00:00	2
      John Doe	10/05/1987 00:00	10/11/2021 00:00	3
      John Doe	10/05/1987 00:00	10/10/2021 00:00	4
      John Doe	10/05/1987 00:00	NULL 	                5

      Attachments

        Issue Links

          Activity

            People

              asolimando Alessandro Solimando
              asolimando Alessandro Solimando
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m