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

Indicator columns not preserved by RelFieldTrimmer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • core
    • None

    Description

      CALCITE-828 introduced the usage of RelBuilder in RelFieldTrimmer. In Hive, we are hitting an issue in RelFieldTrimmer with the following query:

      SELECT a FROM T1 GROUP BY a GROUPING SETS (a);
      

      The problem is that the indicator boolean in the Aggregate operator is set to true, as grouping sets are present. In particular, the plan is the following:

      HiveAggregate(group=[{0}] indicator=[true])
        HiveProject(a=[$0])
          HiveTableScan(table=[[default.t1]])
      

      However, RelFieldTrimmer will remove the indicator columns, as the number of GroupingSets is <1. This creates a mismatch in the number of columns that results in assertion error. By the definition of the trim function over an Aggregate in RelFieldTrimmer, indicator columns should not be removed.

      PS. I tried to reproduce the issue in Calcite using the following query:

      select ename, grouping(ename) from emp group by ename, grouping sets (ename)
      

      But I could not, as Calcite infers directly the constant value for the grouping column.

      Attachments

        Issue Links

          Activity

            People

              jcamacho Jesús Camacho Rodríguez
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: