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=[[]])
.