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

Invalid column ref error in order by when using column alias in select clause and using having

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 0.13.0
    • None
    • Query Processor
    • None

    Description

      Hive CLI session:

      hive> create table abc(foo int, bar string);
      OK
      Time taken: 0.633 seconds
      hive> select foo as c0, count(*) as c1 from abc group by foo, bar having bar like '%abc%' order by foo;
      FAILED: SemanticException [Error 10004]: Line 1:93 Invalid table alias or column reference 'foo': (possible column names are: c0, c1)
      

      Without having clause, the query runs fine, example:

      select foo as c0, count(*) as c1 from abc group by foo, bar order by foo;
      

      The above queries run well with CBO on in Hive master. We tested other queries as can be seen in the attachment. The summary is (1) Hive does not allow alias in group by; (2) Hive does not allow alias in having. The problem will appear only when the first query is run with CBO off. However, CBO should be on as default. Thus, we mark it as won't fix.

      Attachments

        1. HIVE-7693.01.patch
          4 kB
          Pengcheng Xiong
        2. HIVE-7693.02.patch
          10 kB
          Pengcheng Xiong
        3. HIVE-7693.03.patch
          10 kB
          Pengcheng Xiong
        4. HIVE-7693.04.patch
          13 kB
          Pengcheng Xiong
        5. HIVE-7693.05.patch
          11 kB
          Pengcheng Xiong
        6. HIVE-7693.06.patch
          11 kB
          Pengcheng Xiong
        7. HIVE-7693.07.patch
          11 kB
          Pengcheng Xiong
        8. HIVE-7693.08.patch
          16 kB
          Pengcheng Xiong
        9. testingResults.pdf
          40 kB
          Pengcheng Xiong

        Issue Links

          Activity

            People

              pxiong Pengcheng Xiong
              deepesh Deepesh Khandelwal
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: