[ https://issues.apache.org/jira/browse/CALCITE-2344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16496708#comment-16496708 ]
Laurent Goujon commented on CALCITE-2344: ----------------------------------------- I tried the following query: {code:sql} select empno, deptno, w_count from ( select empno, deptno, count(empno) over (ROWS BETWEEN 10 PRECEDING AND 1 PRECEDING) w_count from emp ) sub_query where w_count is null {code} In {{RelOptRulesTest}} I configured a preplanner with the {{ProjectToWindowRule.PROJECT}} rule and then a planner with the {{ReduceExpressionsRule.PROJECT_INSTANCE}}. I got the following exception: {noformat} java.lang.AssertionError: Cannot add expression of different type to set: set type is RecordType(INTEGER NOT NULL EMPNO, INTEGER NOT NULL DEPTNO, BIGINT NOT NULL W_COUNT) NOT NULL expression type is RecordType(INTEGER NOT NULL EMPNO, INTEGER NOT NULL DEPTNO, BIGINT W_COUNT) NOT NULL set is rel#26:LogicalProject(input=HepRelVertex#25,EMPNO=$0,DEPTNO=$1,W_COUNT=$2) expression is LogicalProject#28 at org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:410) 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.ReduceExpressionsRule$ProjectReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:290) at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317) at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:556) at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:415) at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:252) at org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127) at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:211) at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:198) at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:170) at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:315) at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:299) at org.apache.calcite.test.RelOptRulesTest.testIsNullPushDown2(RelOptRulesTest.java:3027) {noformat} > Wrong constant reduction over windows function > ---------------------------------------------- > > Key: CALCITE-2344 > URL: https://issues.apache.org/jira/browse/CALCITE-2344 > Project: Calcite > Issue Type: Bug > Reporter: Laurent Goujon > Assignee: Laurent Goujon > Priority: Major > > {{RexUtil}} might incorrectly infer a IS NULL predicate would cause a > reference over a window function to return null, but a window function type > is never nullable. -- This message was sent by Atlassian JIRA (v7.6.3#76005)