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

Table alias cannot be used in GROUPING SETS clause if there are more than one column in it

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 0.13.0
    • None
    • SQL
    • None

    Description

      The following SQL doesn't work:

      EXPLAIN 
      SELECT alias.a, alias.b, alias.c, COUNT(DISTINCT d) 
      FROM table_name alias 
      GROUP BY alias.a, alias.b, alias.c 
      GROUPING SETS( (alias.a), (alias.b, alias.a) ); 
      FAILED: ParseException line 15:34 missing ) at ',' near '<EOF>' 
      line 16:0 extraneous input ')' expecting EOF near '<EOF>' 
      

      The following SQL works (without alias in grouping set):

      EXPLAIN 
      SELECT a, b, c, COUNT(DISTINCT d) 
      FROM table_name 
      GROUP BY a, b, c 
      GROUPING SETS( (a), (b, a) ); 
      

      Alias works for just one column:

      EXPLAIN 
      SELECT alias.a, alias.b, alias.c, COUNT(DISTINCT d) 
      FROM table_name alias 
      GROUP BY alias.a, alias.b, alias.c 
      GROUPING SETS( (alias.a) ); 
      

      Using alias in GROUPING SETS could be very useful if multiple tables are involved in the SELECT (via JOIN)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Yibing Yibing Shi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: