StmtTableScan tableScan = scanNode.getTableScan();
if (tableScan instanceof StmtSubqueryScan) {
CompiledPlan betsCostPlan = ((StmtSubqueryScan)tableScan).getBestCostPlan();
assert (betsCostPlan != null);
AbstractPlanNode subQueryRoot = betsCostPlan.rootPlanGraph;
subQueryRoot.disconnectParents();
scanNode.addAndLinkChild(subQueryRoot);
}
} else {
for (int i = 0; i < parentPlan.getChildCount(); ++i) {
connectChildrenBestPlans(parentPlan.getChild(i));