pengzhiwei created CALCITE-2424: ----------------------------------- Summary: AggregateProjectPullUpConstantsRule throws AssertionError when sql has "where 'a' is null" Key: CALCITE-2424 URL: https://issues.apache.org/jira/browse/CALCITE-2424 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.16.0 Reporter: pengzhiwei Assignee: Julian Hyde Fix For: 1.17.0 Attachments: 屏幕快照 2018-07-23 下午4.09.55.png, 屏幕快照 2018-07-23 下午4.11.36.png
In the sql shown bellow: {code:java} select 'a',-emp.deptno from emp where 'a' is null group by 'a',-emp.deptno {code} The AggregateProjectPullUpConstantsRule throws an Error like this: {code:java} java.lang.AssertionError: Cannot add expression of different type to set: set type is RecordType(CHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL EXPR$0, INTEGER NOT NULL EXPR$1) NOT NULL expression type is RecordType(CHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL EXPR$0, CHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL EXPR$1) NOT NULL set is rel#9:LogicalAggregate(input=HepRelVertex#8,group={0, 1}) expression is LogicalProject#11 at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:380) at org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:57) at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:234) at org.apache.calcite.rel.rules.AggregateProjectPullUpConstantsRule.onMatch(AggregateProjectPullUpConstantsRule.java:194) at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:315) {code} I find the problem arises out of the "where 'a' is null" filter condition which is always false.And it result in the relBuilder#aggregate failed to generate the new aggregate RelNode in the code as followed in AggregateProjectPullUpConstantsRule: !屏幕快照 2018-07-23 下午4.11.36.png! I think we should do nothing in the ruler in such case when the relBuilder failed to generate the new aggreate RelNode. I have submit a PR,can you have a check? Thank you. -- This message was sent by Atlassian JIRA (v7.6.3#76005)