You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Hequn Cheng (JIRA)" <ji...@apache.org> on 2019/01/24 01:46:00 UTC

[jira] [Created] (CALCITE-2801) Check input type in AggregateUnionAggregateRule when remove the bottom Aggregate

Hequn Cheng created CALCITE-2801:
------------------------------------

             Summary: Check input type in AggregateUnionAggregateRule when remove the bottom Aggregate
                 Key: CALCITE-2801
                 URL: https://issues.apache.org/jira/browse/CALCITE-2801
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Hequn Cheng
            Assignee: Hequn Cheng


In {{AggregateUnionAggregateRule}}, we may remove the bottom Aggregate and use it's input as the new input of Union directly. However, the bottom Aggregate and it's input may not share the same row type. As Union requires all inputs with a same row type, once we remove the bottom Aggregate, an exception will be thrown.

The exception can be reproduced by the following test:
{code:java}
  @Test public void testPullAggregateThroughUnion() {
    HepProgram program = new HepProgramBuilder()
        .addRuleInstance(AggregateProjectMergeRule.INSTANCE)
        .addRuleInstance(AggregateUnionAggregateRule.INSTANCE)
        .build();

    final String sql = "select job, deptno from"
            + " (select job, deptno from emp as e1"
            + " group by job, deptno"
            + "  union all"
            + " select job, deptno from emp as e2"
            + " group by job, deptno)"
            + " group by job, deptno";

    sql(sql).with(program).check();
  }
{code}

I see two option to solve the problem:
- Check the input type in {{AggregateUnionAggregateRule}} and exit the rule directly.
- Add a Project with a same row type to the bottom Aggregate. 

What do you guys think? Thanks a lot.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)