switch (node.getType()) {
case INNER:
// Prefer the right candidate over the left candidate
if (rightIndexCandidate.isPresent()) {
return new IndexJoinNode(idAllocator.getNextId(), IndexJoinNode.Type.INNER, leftRewritten, rightIndexCandidate.get(), createEquiJoinClause(leftJoinSymbols, rightJoinSymbols));
}
else if (leftIndexCandidate.isPresent()) {
return new IndexJoinNode(idAllocator.getNextId(), IndexJoinNode.Type.INNER, rightRewritten, leftIndexCandidate.get(), createEquiJoinClause(rightJoinSymbols, leftJoinSymbols));
}
break;
case LEFT:
if (rightIndexCandidate.isPresent()) {
return new IndexJoinNode(idAllocator.getNextId(), IndexJoinNode.Type.SOURCE_OUTER, leftRewritten, rightIndexCandidate.get(), createEquiJoinClause(leftJoinSymbols, rightJoinSymbols));
}
break;
case RIGHT:
if (leftIndexCandidate.isPresent()) {
return new IndexJoinNode(idAllocator.getNextId(), IndexJoinNode.Type.SOURCE_OUTER, rightRewritten, leftIndexCandidate.get(), createEquiJoinClause(rightJoinSymbols, leftJoinSymbols));
}
break;
default:
throw new IllegalArgumentException("Unknown type: " + node.getType());