@Test public void shouldDoNothingWithLeftOuterJoin() { PlanNode joinNode = new PlanNode(Type.JOIN); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); PlanNode lhs = new PlanNode(Type.SOURCE, joinNode); PlanNode rhs = new PlanNode(Type.SOURCE, joinNode); PlanNode result = rule.execute(context, joinNode, new LinkedList<OptimizerRule>()); assertThat(result, is(sameInstance(joinNode))); assertThat(joinNode.getProperty(Property.JOIN_TYPE, JoinType.class), is(JoinType.LEFT_OUTER)); assertThat(joinNode.getFirstChild(), is(sameInstance(lhs))); assertThat(joinNode.getLastChild(), is(sameInstance(rhs))); assertThat(joinNode.getChildCount(), is(2)); }
@Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode joinNode : plan.findAllAtOrBelow(Type.JOIN)) { if (JoinType.RIGHT_OUTER == joinNode.getProperty(Property.JOIN_TYPE, JoinType.class)) { PlanNode left = joinNode.getFirstChild(); left.removeFromParent(); left.setParent(joinNode); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); } } return plan; }
RightOuterToLeftOuterJoins implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode joinNode : plan.findAllAtOrBelow(Type.JOIN)) { if (JoinType.RIGHT_OUTER == joinNode.getProperty(Property.JOIN_TYPE, JoinType.class)) { PlanNode left = joinNode.getFirstChild(); left.removeFromParent(); left.setParent(joinNode); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); } } return plan; } }
RightOuterToLeftOuterJoins implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode joinNode : plan.findAllAtOrBelow(Type.JOIN)) { if (JoinType.RIGHT_OUTER == joinNode.getProperty(Property.JOIN_TYPE, JoinType.class)) { PlanNode left = joinNode.getFirstChild(); left.removeFromParent(); left.setParent(joinNode); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); } } return plan; }  }
RightOuterToLeftOuterJoins implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode joinNode : plan.findAllAtOrBelow(Type.JOIN)) { if (JoinType.RIGHT_OUTER == joinNode.getProperty(Property.JOIN_TYPE, JoinType.class)) { PlanNode left = joinNode.getFirstChild(); left.removeFromParent(); left.setParent(joinNode); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); } } return plan; }  @Override PlanNode execute( QueryContext context,
                             PlanNode plan,
                             LinkedList<OptimizerRule> ruleStack ); @Override String toString(); }
RightOuterToLeftOuterJoins implements OptimizerRule { @Override public PlanNode execute( QueryContext context, PlanNode plan, LinkedList<OptimizerRule> ruleStack ) { for (PlanNode joinNode : plan.findAllAtOrBelow(Type.JOIN)) { if (JoinType.RIGHT_OUTER == joinNode.getProperty(Property.JOIN_TYPE, JoinType.class)) { PlanNode left = joinNode.getFirstChild(); left.removeFromParent(); left.setParent(joinNode); joinNode.setProperty(Property.JOIN_TYPE, JoinType.LEFT_OUTER); } } return plan; }  @Override PlanNode execute( QueryContext context,
                             PlanNode plan,
                             LinkedList<OptimizerRule> ruleStack ); @Override String toString(); static final RightOuterToLeftOuterJoins INSTANCE; }