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

GROUPING() function errors out due to case-sensitivity of function name

    XMLWordPrintableJSON

Details

    Description

      The following errors out:

      explain cbo select GROUPING(l_suppkey) from lineitem group by l_suppkey with rollup;
      Error: Error while compiling statement: FAILED: SemanticException [Error 10015]: Line 1:19 Arguments length mismatch 'l_suppkey': grouping() requires at least 2 argument, got 1 (state=21000,code=10015)
      

      Lowercase grouping() succeeds:

      explain cbo select grouping(l_suppkey) from lineitem group by l_suppkey with rollup;
      
      +----------------------------------------------------+
      |                      Explain                       |
      +----------------------------------------------------+
      | CBO PLAN:                                          |
      | HiveProject(_o__c0=[grouping($1, 0:BIGINT)])       |
      |   HiveAggregate(group=[{0}], groups=[[{0}, {}]], GROUPING__ID=[GROUPING__ID()]) |
      |     HiveProject(l_suppkey=[$2])                    |
      |       HiveTableScan(table=[[tpch, lineitem]], table:alias=[lineitem]) |
      |                                                    |
      +----------------------------------------------------+
      

      This is likely due to the SemanticAnalyzer doing a case-sensitive compare here:

       @Override
            public Object post(Object t) {
               ....
                if (func.getText().equals("grouping") && func.getChildCount() == 0) {
      

      We should fix this to make it case-insensitive comparison. There might be other places to examine too for grouping function.

      Attachments

        Issue Links

          Activity

            People

              soumyakanti.das Soumyakanti Das
              amansinha Aman Sinha
              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 - 1h
                  1h