@Override public LogicalNode visitUnion(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { LogicalPlan.QueryBlock leftBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext leftContext = new LogicalPlanner.PlanContext(ctx, leftBlock); LogicalNode leftChild = visit(leftContext, new Stack<>(), expr.getLeft()); leftBlock.setRoot(leftChild); ctx.getQueryBlock().registerExprWithNode(expr.getLeft(), leftChild); LogicalPlan.QueryBlock rightBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext rightContext = new LogicalPlanner.PlanContext(ctx, rightBlock); LogicalNode rightChild = visit(rightContext, new Stack<>(), expr.getRight()); rightBlock.setRoot(rightChild); ctx.getQueryBlock().registerExprWithNode(expr.getRight(), rightChild); UnionNode unionNode = new UnionNode(ctx.getPlan().newPID()); unionNode.setLeftChild(leftChild); unionNode.setRightChild(rightChild); unionNode.setInSchema(leftChild.getOutSchema()); unionNode.setOutSchema(leftChild.getOutSchema()); unionNode.setDistinct(expr.isDistinct()); return unionNode; }
@Override public LogicalNode visitUnion(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { LogicalPlan.QueryBlock leftBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext leftContext = new LogicalPlanner.PlanContext(ctx, leftBlock); LogicalNode leftChild = visit(leftContext, new Stack<Expr>(), expr.getLeft()); leftBlock.setRoot(leftChild); ctx.getQueryBlock().registerExprWithNode(expr.getLeft(), leftChild); LogicalPlan.QueryBlock rightBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext rightContext = new LogicalPlanner.PlanContext(ctx, rightBlock); LogicalNode rightChild = visit(rightContext, new Stack<Expr>(), expr.getRight()); rightBlock.setRoot(rightChild); ctx.getQueryBlock().registerExprWithNode(expr.getRight(), rightChild); UnionNode unionNode = new UnionNode(ctx.getPlan().newPID()); unionNode.setLeftChild(leftChild); unionNode.setRightChild(rightChild); unionNode.setInSchema(leftChild.getOutSchema()); unionNode.setOutSchema(leftChild.getOutSchema()); unionNode.setDistinct(expr.isDistinct()); return unionNode; }
@Override public LogicalNode postHook(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Expr expr, LogicalNode result) throws TajoException { // If non-from statement, result can be null. It avoids that case. if (result != null) { // setNode method registers each node to corresponding block and plan. ctx.getQueryBlock().registerNode(result); // It makes a map between an expr and a logical node. ctx.getQueryBlock().registerExprWithNode(expr, result); } return result; }
@Override public LogicalNode postHook(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Expr expr, LogicalNode result) throws TajoException { // If non-from statement, result can be null. It avoids that case. if (result != null) { // setNode method registers each node to corresponding block and plan. ctx.getQueryBlock().registerNode(result); // It makes a map between an expr and a logical node. ctx.getQueryBlock().registerExprWithNode(expr, result); } return result; }