Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-24424

Support ANSI-SQL compliant syntax for GROUPING SET

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.4.0
    • Component/s: SQL
    • Labels:
      None
    • Target Version/s:

      Description

      Currently, our Group By clause follows Hive https://cwiki.apache.org/confluence/display/Hive/Enhanced+Aggregation,+Cube,+Grouping+and+Rollup :
      However, this does not match ANSI SQL compliance. The proposal is to update our parser and analyzer for ANSI compliance.
      For example,

      GROUP BY col1, col2 GROUPING SET ...
      

      It is nice to support ANSI SQL syntax at the same time.

      GROUP BY GROUPING SET(...) 
      

      Note, we only need to support one-level grouping set in this stage. That means, nested grouping set is not supported.

      Note, we should not break the existing syntax. The parser changes should be like

      group-by-expressions
      
      >>-GROUP BY----+-hive-sql-group-by-expressions-----+---><
                     '-ansi-sql-grouping-set-expressions-'    
      
      hive-sql-group-by-expressions
      
                              '--GROUPING SETS--(--grouping-set-expressions--)--'
         .-,--------------.   +--WITH CUBE--------------------------------------+
         V                |   +--WITH ROLLUP------------------------------------+
      >>---+-expression-+-+---+-------------------------------------------------+-><
      
      grouping-expressions-list
      
         .-,--------------.  
         V                |  
      >>---+-expression-+-+--><
      
      
      grouping-set-expressions
      
          .-,----------------------------.
          |      .-,--------------.      |
          |      V                |      |
          V '-(------expression---+-)-'  |
      >>----+-expression--------------+--+-><
      
      
      ansi-sql-grouping-set-expressions
      
      >>-+-ROLLUP--(--grouping-expression-list--)---------+--><
         +-CUBE--(--grouping-expression-list--)-----------+   
         '-GROUPING SETS--(--grouping-set-expressions--)--'  
      

       

        Attachments

          Activity

            People

            • Assignee:
              dkbiswal Dilip Biswal
              Reporter:
              smilegator Xiao Li
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: