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

Subquery GroupBy with Distinct SemanticException: Invalid column reference

    XMLWordPrintableJSON

Details

    Description

      CREATE TABLE tmp_src1(
        `npp` string,
        `nsoc` string) stored as orc;
      
      INSERT INTO tmp_src1 (npp,nsoc) VALUES ('1-1000CG61', '7273111');
      
      SELECT `min_nsoc`
      FROM
           (SELECT `npp`,
                   MIN(`nsoc`) AS `min_nsoc`,
                   COUNT(DISTINCT `nsoc`) AS `nb_nsoc`
            FROM tmp_src1
            GROUP BY `npp`) `a`
      WHERE `nb_nsoc` > 0;
      

      Issue:

      org.apache.hadoop.hive.ql.parse.SemanticException: Line 0:-1 Invalid column reference 'nsoc' at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genGroupByPlanGroupByOperator1(SemanticAnalyzer.java:5405)
      

      Query runs fine when we include `nb_nsoc` in the Select expression

      Attachments

        Issue Links

          Activity

            People

              pgaref Panagiotis Garefalakis
              pgaref Panagiotis Garefalakis
              Votes:
              0 Vote for this issue
              Watchers:
              4 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 - 50m
                  50m