SubPlanBuilder source = node.getSource().accept(this, context);
SubPlanBuilder filteringSource = node.getFilteringSource().accept(this, context);
if (source.isPartitioned() || filteringSource.isPartitioned()) {
filteringSource.setRoot(new SinkNode(idAllocator.getNextId(), filteringSource.getRoot(), filteringSource.getRoot().getOutputSymbols()));
source.setRoot(new SemiJoinNode(node.getId(),
source.getRoot(),
new ExchangeNode(idAllocator.getNextId(), filteringSource.getId(), filteringSource.getRoot().getOutputSymbols()),
node.getSourceJoinSymbol(),
node.getFilteringSourceJoinSymbol(),
node.getSemiJoinOutput()));
source.addChild(filteringSource.build());
return source;
}
else {
SemiJoinNode semiJoinNode = new SemiJoinNode(node.getId(), source.getRoot(), filteringSource.getRoot(), node.getSourceJoinSymbol(), node.getFilteringSourceJoinSymbol(), node.getSemiJoinOutput());
return newSubPlan(semiJoinNode)
.setUnpartitionedSource()
.setChildren(Iterables.concat(source.getChildren(), filteringSource.getChildren()));
}
}