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

Query fails with SemanticException if column referenced with name in ORDER by

    XMLWordPrintableJSON

Details

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

    Description

      Query fails with 'Invalid column reference' error if the column in Order by clause is not referenced similar to Group By clause. Like below 2 queries will compile correctly but the third one will fail. Attached repro.q

      CREATE VIEW view_order_by_test AS SELECT to_date(`order_by_test`.`result_date`) AS `process_date`,COUNT AS `count`
      FROM `order_by_test`
      GROUP BY to_date(`order_by_test`.`result_date`)
      ORDER BY to_date(`order_by_test`.`result_date`) DESC;
      ---Successful
      CREATE VIEW view_order_by_test AS SELECT to_date(`result_date`) AS `process_date`,COUNT AS `count`
      FROM `order_by_test`
      GROUP BY to_date(`result_date`)
      ORDER BY to_date(`result_date`) DESC;
      --Successful
      CREATE VIEW view_order_by_test AS SELECT to_date(`order_by_test`.`result_date`) AS `process_date`,COUNT AS `count`
      FROM `order_by_test`
      GROUP BY to_date(`order_by_test`.`result_date`)
      ORDER BY to_date(`result_date`) DESC; 
      --Failure
      

      Both column name and alias use should be supported for the "ORDER BY" clause.

       

       

       

      Attachments

        1. repro.q
          0.3 kB
          Riju Trivedi

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rtrivedi12 Riju Trivedi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: