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

[jira] [Created] (CALCITE-2466) RexSimplify incorrectly simplify conjunction statement with null literal

Shuyi Chen created CALCITE-2466:
-----------------------------------

             Summary: RexSimplify incorrectly simplify conjunction statement with null literal
                 Key: CALCITE-2466
                 URL: https://issues.apache.org/jira/browse/CALCITE-2466
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Shuyi Chen
            Assignee: Julian Hyde
             Fix For: 1.18.0


This can be reproduced using the following test:

{code:java}
 @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));
  }
{code}

In this test, 
{code:java}
NAME <> '' AND employees <> null
{code} is always evaluated to false incorrectly, so the optimized plan is 
{code:java}
LogicalProject(DEPTNO=[$0])
  LogicalValues(tuples=[[]])
{code}.






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