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

RexSimplify incorrectly simplify conjunction statement with null literal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • 1.18.0
    • core
    • None

    Description

      This can be reproduced using the following test:

       @Test public void testFilterReduction() throws Exception {
          HepProgramBuilder programBuilder = HepProgram.builder();
          programBuilder.addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE);
          HepPlanner planner = new HepPlanner(programBuilder.build());
          final String sql = "select deptno from dept_nested where NAME <> '' AND employees <> null";
          planner.setRoot(tester.convertSqlToRel(sql).rel);
          RelNode bestRel = planner.findBestExp();
      
          assertEquals(
              "LogicalProject(DEPTNO=[$0])\n" +
              "  LogicalFilter(condition=[AND(<>($1, ''), <>($3, null))])\n" +
              "    LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])\n",
              RelOptUtil.toString(bestRel));
        }
      

      In this test,

      NAME <> '' AND employees <> null
      

      is always evaluated to false incorrectly, so the optimized plan is

      LogicalProject(DEPTNO=[$0])
        LogicalValues(tuples=[[]])
      

      .

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            suez1224 Shuyi Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: