@Test
public void shouldOptimizePlanForEquiJoinQuery() {

    node = optimize("SELECT t1.c11, t1.c12, t2.c23 FROM t1 JOIN t2 ON t1.c11 = t2.c21");
    multipleSelectors = true;
    // Create the expected plan ...
    PlanNode project = new PlanNode(Type.PROJECT, selector("t2"), selector("t1"));
    project.setProperty(Property.PROJECT_COLUMNS, columns(column("t1", "c11"), column("t1", "c12"), column("t2", "c23")));
    PlanNode join = new PlanNode(Type.JOIN, project, selector("t2"), selector("t1"));
    join.setProperty(Property.JOIN_ALGORITHM, JoinAlgorithm.NESTED_LOOP);
    join.setProperty(Property.JOIN_TYPE, JoinType.INNER);
    join.setProperty(Property.JOIN_CONDITION, new EquiJoinCondition(selector("t1"), "c11", selector("t2"), "c21"));
    PlanNode leftAccess = new PlanNode(Type.ACCESS, join, selector("t1"));
    PlanNode leftProject = new PlanNode(Type.PROJECT, leftAccess, selector("t1"));
    leftProject.setProperty(Property.PROJECT_COLUMNS, columns(column("t1", "c11"), column("t1", "c12")));
    PlanNode leftSource = new PlanNode(Type.SOURCE, leftProject, selector("t1"));
    leftSource.setProperty(Property.SOURCE_NAME, selector("t1"));
    leftSource.setProperty(Property.SOURCE_COLUMNS, context.getSchemata().getTable(selector("t1")).getColumns());
    PlanNode rightAccess = new PlanNode(Type.ACCESS, join, selector("t2"));
    PlanNode rightProject = new PlanNode(Type.PROJECT, rightAccess, selector("t2"));
    rightProject.setProperty(Property.PROJECT_COLUMNS, columns(column("t2", "c23"), nonSelectedColumn("t2", "c21")));
    PlanNode rightSource = new PlanNode(Type.SOURCE, rightProject, selector("t2"));
    rightSource.setProperty(Property.SOURCE_NAME, selector("t2"));
    rightSource.setProperty(Property.SOURCE_COLUMNS, context.getSchemata().getTable(selector("t2")).getColumns());
    // Compare the expected and actual plan ...
    assertPlanMatches(project);
}