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

Match nullability when reducing expressions in a Project

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Component/s: None
    • Labels:
      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:
      

        Issue Links

          Activity

          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/9adf2597 .
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Resolved in release 1.5.0 (2015-11-10)

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.5.0 (2015-11-10)

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              pxiong Pengcheng Xiong
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development