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

Indicator columns not preserved by RelFieldTrimmer

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Component/s: core
    • Labels:
      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.

        Issue Links

          Activity

          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Julian Hyde, created a pull request in https://github.com/apache/calcite/pull/163

          The fix explicitly sets the indicator boolean when we create a new Aggregate operator, as it was done before CALCITE-828 .

          Could you take a look?

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Julian Hyde , created a pull request in https://github.com/apache/calcite/pull/163 The fix explicitly sets the indicator boolean when we create a new Aggregate operator, as it was done before CALCITE-828 . Could you take a look?
          Hide
          julianhyde Julian Hyde added a comment -

          +1

          Sorry I broke this in CALCITE-828.

          Show
          julianhyde Julian Hyde added a comment - +1 Sorry I broke this in CALCITE-828 .
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - - edited
          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - - edited Thanks for checking Julian Hyde Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/b8e09fe
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Resolved in release 1.5.0 (2015-11-10)

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.5.0 (2015-11-10)

            People

            • Assignee:
              jcamachorodriguez Jesus Camacho Rodriguez
              Reporter:
              jcamachorodriguez Jesus Camacho Rodriguez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development