private PhysicalExec createPlanRecursive()

in tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PhysicalPlannerImpl.java [115:223]


  private PhysicalExec createPlanRecursive(TaskAttemptContext ctx, LogicalNode logicalNode, Stack<LogicalNode> stack)
      throws IOException {
    PhysicalExec leftExec;
    PhysicalExec rightExec;

    switch (logicalNode.getType()) {

      case ROOT:
        LogicalRootNode rootNode = (LogicalRootNode) logicalNode;
        stack.push(rootNode);
        leftExec = createPlanRecursive(ctx, rootNode.getChild(), stack);
        stack.pop();
        return leftExec;

      case EXPRS:
        EvalExprNode evalExpr = (EvalExprNode) logicalNode;
        return new EvalExprExec(ctx, evalExpr);

      case CREATE_TABLE:
      case INSERT:
      case STORE:
        StoreTableNode storeNode = (StoreTableNode) logicalNode;
        stack.push(storeNode);
        leftExec = createPlanRecursive(ctx, storeNode.getChild(), stack);
        stack.pop();
        return createStorePlan(ctx, storeNode, leftExec);

      case SELECTION:
        SelectionNode selNode = (SelectionNode) logicalNode;
        stack.push(selNode);
        leftExec = createPlanRecursive(ctx, selNode.getChild(), stack);
        stack.pop();
        return new SelectionExec(ctx, selNode, leftExec);

      case PROJECTION:
        ProjectionNode prjNode = (ProjectionNode) logicalNode;
        stack.push(prjNode);
        leftExec = createPlanRecursive(ctx, prjNode.getChild(), stack);
        stack.pop();
        return new ProjectionExec(ctx, prjNode, leftExec);

      case TABLE_SUBQUERY: {
        TableSubQueryNode subQueryNode = (TableSubQueryNode) logicalNode;
        stack.push(subQueryNode);
        leftExec = createPlanRecursive(ctx, subQueryNode.getSubQuery(), stack);
        stack.pop();
        return new ProjectionExec(ctx, subQueryNode, leftExec);

      }

      case PARTITIONS_SCAN:
      case SCAN:
        leftExec = createScanPlan(ctx, (ScanNode) logicalNode, stack);
        return leftExec;

      case GROUP_BY:
        GroupbyNode grpNode = (GroupbyNode) logicalNode;
        stack.push(grpNode);
        leftExec = createPlanRecursive(ctx, grpNode.getChild(), stack);
        stack.pop();
        return createGroupByPlan(ctx, grpNode, leftExec);

      case HAVING:
        HavingNode havingNode = (HavingNode) logicalNode;
        stack.push(havingNode);
        leftExec = createPlanRecursive(ctx, havingNode.getChild(), stack);
        stack.pop();
        return new HavingExec(ctx, havingNode, leftExec);

      case SORT:
        SortNode sortNode = (SortNode) logicalNode;
        stack.push(sortNode);
        leftExec = createPlanRecursive(ctx, sortNode.getChild(), stack);
        stack.pop();
        return createSortPlan(ctx, sortNode, leftExec);

      case JOIN:
        JoinNode joinNode = (JoinNode) logicalNode;
        stack.push(joinNode);
        leftExec = createPlanRecursive(ctx, joinNode.getLeftChild(), stack);
        rightExec = createPlanRecursive(ctx, joinNode.getRightChild(), stack);
        stack.pop();
        return createJoinPlan(ctx, joinNode, leftExec, rightExec);

      case UNION:
        UnionNode unionNode = (UnionNode) logicalNode;
        stack.push(unionNode);
        leftExec = createPlanRecursive(ctx, unionNode.getLeftChild(), stack);
        rightExec = createPlanRecursive(ctx, unionNode.getRightChild(), stack);
        stack.pop();
        return new UnionExec(ctx, leftExec, rightExec);

      case LIMIT:
        LimitNode limitNode = (LimitNode) logicalNode;
        stack.push(limitNode);
        leftExec = createPlanRecursive(ctx, limitNode.getChild(), stack);
        stack.pop();
        return new LimitExec(ctx, limitNode.getInSchema(),
            limitNode.getOutSchema(), leftExec, limitNode);

      case BST_INDEX_SCAN:
        IndexScanNode indexScanNode = (IndexScanNode) logicalNode;
        leftExec = createIndexScanExec(ctx, indexScanNode);
        return leftExec;

      default:
        return null;
    }
  }