You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "pengzhiwei (JIRA)" <ji...@apache.org> on 2018/08/06 13:24:00 UTC

[jira] [Created] (CALCITE-2448) AggregateProjectPullUpConstantsRule throws AssertionError

pengzhiwei created CALCITE-2448:
-----------------------------------

             Summary: AggregateProjectPullUpConstantsRule throws AssertionError
                 Key: CALCITE-2448
                 URL: https://issues.apache.org/jira/browse/CALCITE-2448
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: pengzhiwei
            Assignee: Julian Hyde
         Attachments: 屏幕快照 2018-08-06 下午9.09.15.png, 屏幕快照 2018-08-06 下午9.13.56.png, 屏幕快照 2018-08-06 下午9.19.48.png

In the sql as followed:
{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}
The reason is that the relBuilder#aggregate failed to generate new aggregate node when the filer condition is always false,just return as followed in RelBuilder:

!屏幕快照 2018-08-06 下午9.09.15.png!

And then the project created later after relBuilder#aggregate is not really based on the a aggregate node which result in the error.

!屏幕快照 2018-08-06 下午9.13.56.png!

I fix the problem by add a logic if the relBuilder#aggregate has not generated a aggregate node then just return this ruler,just like this:

!屏幕快照 2018-08-06 下午9.19.48.png!

Can you have check for me,thanks!

 



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