public void transitiveInference() throws Exception {
final DiffRepository diffRepos = getDiffRepos();
String sql = diffRepos.expand(null, "${sql}");
HepProgram program = new HepProgramBuilder()
.addRuleInstance(PushFilterPastJoinRule.DUMB_FILTER_ON_JOIN)
.addRuleInstance(PushFilterPastJoinRule.JOIN)
.addRuleInstance(PushFilterPastProjectRule.INSTANCE)
.addRuleInstance(PushFilterPastSetOpRule.INSTANCE)
.build();
HepPlanner planner = new HepPlanner(program);
RelNode relInitial = tester.convertSqlToRel(sql);
assertTrue(relInitial != null);
List<RelMetadataProvider> list = Lists.newArrayList();
DefaultRelMetadataProvider defaultProvider =
new DefaultRelMetadataProvider();
list.add(defaultProvider);
planner.registerMetadataProviders(list);
RelMetadataProvider plannerChain = ChainedRelMetadataProvider.of(list);
relInitial.getCluster().setMetadataProvider(
new CachingRelMetadataProvider(plannerChain, planner));
planner.setRoot(relInitial);
RelNode relAfter = planner.findBestExp();
String planBefore = NL + RelOptUtil.toString(relAfter);
diffRepos.assertEquals("planBefore", "${planBefore}", planBefore);
HepProgram program2 = new HepProgramBuilder()
.addMatchOrder(HepMatchOrder.BOTTOM_UP)
.addRuleInstance(PushFilterPastJoinRule.DUMB_FILTER_ON_JOIN)
.addRuleInstance(PushFilterPastJoinRule.JOIN)
.addRuleInstance(PushFilterPastProjectRule.INSTANCE)
.addRuleInstance(PushFilterPastSetOpRule.INSTANCE)