"v = 1 and v is null" cannot be simplified to "v = 1" not matter v is nullable or not nullable
If you really mean that "v is not null", I made below test case in RelOptRulesTest.java for illustration: // mgr is nullable @Test public void testDEV() throws Exception { HepProgram program = new HepProgramBuilder() .addRuleInstance(ReduceExpressionsRule.FILTER_INSTANCE) .build(); final String sql = "select deptno" + " from emp" + " where mgr = 10 and mgr is not null"; checkPlanning(new HepPlanner(program), sql); } The plan is LogicalProject(DEPTNO=[$7]) LogicalFilter(condition=[=($3, 10)]) LogicalTableScan(table=[[CATALOG, SALES, EMP]]) Enrico ~ you may try ReduceExpressionsRule.FILTER_INSTANCE Feng Zhu <wellfeng...@gmail.com> 于2019年9月24日周二 下午5:50写道: > Hi, Enrico, > I'm a little confused about your expectations. Could you clarify it? > Moreover, is it right for the below simplification (do you mean v is not > null)? > (v=1 and v is null) -> v=1 > (do you mean v is not null?) > > Best regards > > Enrico Olivelli <eolive...@gmail.com> 于2019年9月24日周二 下午5:41写道: > > > Hi, > > I have a query like > > SELECT * FROM MYTABLE WHERE v = 1 and v is null > > > > I am expecting Calcite to simplify it to > > SELECT * FROM MYTABLE WHERE v = 1 > > > > but this does not happen. > > > > Is any rule I should enable in order to make it happen ? > > > > This is the configuration of my Volcano planner: > > > > final FrameworkConfig config = Frameworks.newConfigBuilder() > > .parserConfig(....) > > .defaultSchema(...) > > .traitDefs(....) > > .programs(Programs.ofRules(Programs.RULE_SET)) > > .build(); > > > > Best regards > > Enrico > > >