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

Match nullability when reducing expressions in a Project

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • None
    • None

    Description

      ReduceExpressionsRule(esp, PROJECT_INSTANCE) does not work with columns that allow null values.

      Repro steps:

      @Test
      	public void testReduceConstants20() throws Exception {
      		HepProgram program = new HepProgramBuilder()
      				.addRuleInstance(ReduceExpressionsRule.PROJECT_INSTANCE)
      				.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE)
      				.addRuleInstance(ReduceExpressionsRule.JOIN_INSTANCE).build();
      
      		checkPlanning(program, "select mgr from emp where mgr=10");
      	}
      

      failing info.:

      testReduceConstants20(org.apache.calcite.test.RelOptRulesTest)  Time elapsed: 0.019 sec  <<< FAILURE!
      java.lang.AssertionError: type mismatch:
      type1:
      INTEGER NOT NULL
      type2:
      INTEGER
      	at org.apache.calcite.plan.RelOptUtil.eq(RelOptUtil.java:1664)
      	at org.apache.calcite.rex.RexUtil.compatibleTypes(RexUtil.java:582)
      	at org.apache.calcite.rel.core.Project.isValid(Project.java:182)
      	at org.apache.calcite.rel.core.Project.<init>(Project.java:85)
      	at org.apache.calcite.rel.logical.LogicalProject.<init>(LogicalProject.java:64)
      	at org.apache.calcite.rel.logical.LogicalProject.create(LogicalProject.java:123)
      	at org.apache.calcite.rel.rules.ReduceExpressionsRule$2.onMatch(ReduceExpressionsRule.java:199)
      	at org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:326)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:515)
      	at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:392)
      	at org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:255)
      	at org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:125)
      	at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:207)
      	at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:194)
      	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:132)
      	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:84)
      	at org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:73)
      	at org.apache.calcite.test.RelOptRulesTest.testReduceConstants20(RelOptRulesTest.java:794)
      
      
      Results :
      
      Failed tests:
        RelOptRulesTest.testReduceConstants20:794->RelOptTestBase.checkPlanning:73->RelOptTestBase.checkPlanning:84->RelOptTestBase.checkPlanning:132 type mismatch:
      

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              pxiong Pengcheng Xiong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: