Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2147

GroupingSets involving rollup resulting into an incorrect plan

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.16.0
    • None
    • None

    Description

      Problem description:

      When rollup or cube expressions are specified as input to grouping_sets ,then instead of handling the rollup or cube expression in LogicalAggregate operator  they are handled in LogicalProject operator which is incorrect.

       

      Basically grouping_sets with rollup/cube expressions as input is not flattened into logical aggregate operator.

       

      Problem Test case:

      create table temp11(a integer, b integer);

      select a,b,count from temp11 group by grouping sets(rollup(a,b),a,b,());

      Test Case output:

      {
        "rels": [
         

      {       "id": "0",       "relOp": "LogicalTableScan",       "table": [         "CATALOG",         "temp11"       ],       "inputs": []     }

      ,
          {
            "id": "1",
            "relOp": "LogicalProject",
            "fields": [
              "$f0",
              "a",
              "b"
            ],
            "exprs": [
              {
                "op": "ROLLUP",          <<--- Incorrect expressioin in LogicalProject operator.
                "operands": [
                 

      {               "input": 0,               "name": "$0"             }

      ,
                 

      {               "input": 1,               "name": "$1"             }

                ]
              },
             

      {           "input": 0,           "name": "$0"         }

      ,
             

      {           "input": 1,           "name": "$1"         }

            ]
          },
          {
            "id": "2",
            "relOp": "LogicalAggregate",
            "group": [
              0,
              1,
              2
            ],
            "groups": [
              [
                0
              ],
              [
                1
              ],
              [
                2
              ],
              []
            ],
            "aggs": [
              {
                "agg": "COUNT",
                "type":

      {             "type": "BIGINT",             "nullable": false           }

      ,
                "distinct": false,
                "operands": []
              }
            ]
          },
          {
            "id": "3",
            "relOp": "LogicalProject",
            "fields": [
              "a",
              "b",
              "EXPR$2"
            ],
            "exprs": [
             

      {           "input": 1,           "name": "$1"         }

      ,
             

      {           "input": 2,           "name": "$2"         }

      ,
             

      {           "input": 3,           "name": "$3"         }

            ]
          }
        ]
      }

      Attachments

        There are no Sub-Tasks for this issue.

        Activity

          People

            julianhyde Julian Hyde
            vamshi.v.krishna@gmail.com Vamshi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: