@Override public RESULT visitUnion(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); result = visit(context, plan, leftBlock, leftBlock.getRoot(), stack); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); visit(context, plan, rightBlock, rightBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getLeftChild(), stack); visit(context, null, null, node.getRightChild(), stack); } stack.pop(); return result; }
@Override public RESULT visitUnion(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); result = visit(context, plan, leftBlock, leftBlock.getRoot(), stack); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); visit(context, plan, rightBlock, rightBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getLeftChild(), stack); visit(context, null, null, node.getRightChild(), stack); } stack.pop(); return result; }
@Override public LogicalNode visitUnion(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode unionNode, Stack<LogicalNode> stack) throws TajoException { LogicalNode leftNode = unionNode.getLeftChild(); List<EvalNode> origins = new ArrayList<>(); origins.addAll(context.pushingDownFilters); // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, leftNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(leftNode)); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, leftNode, context); } LogicalNode rightNode = unionNode.getRightChild(); transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, rightNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(rightNode), rightNode, stack); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, rightNode, context); } // notify all filter matched to upper context.pushingDownFilters.clear(); return unionNode; }
@Override public LogicalNode visitUnion(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); Context leftContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, leftBlock.getName())); Context rightContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, rightBlock.getName())); stack.push(node); visit(leftContext, plan, leftBlock, leftBlock.getRoot(), new Stack<>()); visit(rightContext, plan, rightBlock, rightBlock.getRoot(), new Stack<>()); stack.pop(); return node; }
@Override public LogicalNode visitUnion(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); Context leftContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, leftBlock.getName())); Context rightContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, rightBlock.getName())); stack.push(node); visit(leftContext, plan, leftBlock, leftBlock.getRoot(), new Stack<LogicalNode>()); visit(rightContext, plan, rightBlock, rightBlock.getRoot(), new Stack<LogicalNode>()); stack.pop(); return node; }
@Override public LogicalNode visitUnion(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode unionNode, Stack<LogicalNode> stack) throws TajoException { LogicalNode leftNode = unionNode.getLeftChild(); List<EvalNode> origins = TUtil.newList(context.pushingDownFilters); // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, leftNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(leftNode)); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, leftNode, context); } LogicalNode rightNode = unionNode.getRightChild(); transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, rightNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(rightNode), rightNode, stack); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, rightNode, context); } // notify all filter matched to upper context.pushingDownFilters.clear(); return unionNode; }
LogicalNode leftChild = visit(context, plan, leftQueryBlock, leftQueryBlock.getRoot(), stack); LogicalPlan.QueryBlock rightQueryBlock = plan.getBlock(node.getRightChild()); LogicalNode rightChild = visit(context, plan, rightQueryBlock, rightQueryBlock.getRoot(), stack); stack.pop();
LogicalNode leftChild = visit(context, plan, leftQueryBlock, leftQueryBlock.getRoot(), stack); LogicalPlan.QueryBlock rightQueryBlock = plan.getBlock(node.getRightChild()); LogicalNode rightChild = visit(context, plan, rightQueryBlock, rightQueryBlock.getRoot(), stack); stack.pop();
stack.push(unionNode); leftExec = createPlanRecursive(ctx, unionNode.getLeftChild(), stack); rightExec = createPlanRecursive(ctx, unionNode.getRightChild(), stack); stack.pop(); return new UnionExec(ctx, leftExec, rightExec);
stack.push(unionNode); leftExec = createPlanRecursive(ctx, unionNode.getLeftChild(), stack); rightExec = createPlanRecursive(ctx, unionNode.getRightChild(), stack); stack.pop(); return new UnionExec(ctx, leftExec, rightExec);
UnionNode binaryNode = (UnionNode) node; return estimateOutputVolumeInternal(binaryNode.getLeftChild()) + estimateOutputVolumeInternal(binaryNode.getRightChild()); } else if (node instanceof JoinNode) { JoinNode joinNode = (JoinNode) node;
UnionNode binaryNode = (UnionNode) node; return estimateOutputVolumeInternal(binaryNode.getLeftChild()) + estimateOutputVolumeInternal(binaryNode.getRightChild()); } else if (node instanceof JoinNode) { JoinNode joinNode = (JoinNode) node;
cost = getCost(unionNode.getLeftChild()) + getCost(unionNode.getRightChild()); break;
UnionNode unionNode = (UnionNode) node; cost = getCost(unionNode.getLeftChild()) + getCost(unionNode.getRightChild()); break;
@Test public final void testSetPlan() throws TajoException { QueryContext qc = createQueryContext(); Expr expr = sqlAnalyzer.parse(setStatements[0]); LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot(); assertEquals(NodeType.ROOT, plan.getType()); LogicalRootNode root = (LogicalRootNode) plan; assertEquals(NodeType.UNION, root.getChild().getType()); UnionNode union = root.getChild(); assertEquals(NodeType.PROJECTION, union.getLeftChild().getType()); assertEquals(NodeType.PROJECTION, union.getRightChild().getType()); }
private ProjectionNode makeProjectionForInsertUnion(PlanContext context, InsertNode insertNode) { LogicalNode child = insertNode.getChild(); // add (projection - subquery) to RootBlock and create new QueryBlock for UnionNode TableSubQueryNode subQueryNode = context.plan.createNode(TableSubQueryNode.class); subQueryNode.init(context.queryBlock.getName(), child); subQueryNode.setTargets(PlannerUtil.schemaToTargets(subQueryNode.getOutSchema())); ProjectionNode projectionNode = context.plan.createNode(ProjectionNode.class); projectionNode.setChild(subQueryNode); projectionNode.setInSchema(subQueryNode.getInSchema()); projectionNode.setTargets(subQueryNode.getTargets()); context.queryBlock.registerNode(projectionNode); context.queryBlock.registerNode(subQueryNode); // add child QueryBlock to the UnionNode's QueryBlock UnionNode unionNode = (UnionNode)child; context.queryBlock.unregisterNode(unionNode); QueryBlock unionBlock = context.plan.newQueryBlock(); unionBlock.registerNode(unionNode); unionBlock.setRoot(unionNode); QueryBlock leftBlock = context.plan.getBlock(unionNode.getLeftChild()); QueryBlock rightBlock = context.plan.getBlock(unionNode.getRightChild()); context.plan.disconnectBlocks(leftBlock, context.queryBlock); context.plan.disconnectBlocks(rightBlock, context.queryBlock); context.plan.connectBlocks(unionBlock, context.queryBlock, BlockType.TableSubQuery); context.plan.connectBlocks(leftBlock, unionBlock, BlockType.TableSubQuery); context.plan.connectBlocks(rightBlock, unionBlock, BlockType.TableSubQuery); // set InsertNode's child with ProjectionNode which is created. insertNode.setChild(projectionNode); return projectionNode; }
private ProjectionNode makeProjectionForInsertUnion(PlanContext context, InsertNode insertNode) { LogicalNode child = insertNode.getChild(); // add (projection - subquery) to RootBlock and create new QueryBlock for UnionNode TableSubQueryNode subQueryNode = context.plan.createNode(TableSubQueryNode.class); subQueryNode.init(context.queryBlock.getName(), child); subQueryNode.setTargets(PlannerUtil.schemaToTargets(subQueryNode.getOutSchema())); ProjectionNode projectionNode = context.plan.createNode(ProjectionNode.class); projectionNode.setChild(subQueryNode); projectionNode.setInSchema(subQueryNode.getInSchema()); projectionNode.setTargets(subQueryNode.getTargets()); context.queryBlock.registerNode(projectionNode); context.queryBlock.registerNode(subQueryNode); // add child QueryBlock to the UnionNode's QueryBlock UnionNode unionNode = (UnionNode)child; context.queryBlock.unregisterNode(unionNode); QueryBlock unionBlock = context.plan.newQueryBlock(); unionBlock.registerNode(unionNode); unionBlock.setRoot(unionNode); QueryBlock leftBlock = context.plan.getBlock(unionNode.getLeftChild()); QueryBlock rightBlock = context.plan.getBlock(unionNode.getRightChild()); context.plan.disconnectBlocks(leftBlock, context.queryBlock); context.plan.disconnectBlocks(rightBlock, context.queryBlock); context.plan.connectBlocks(unionBlock, context.queryBlock, BlockType.TableSubQuery); context.plan.connectBlocks(leftBlock, unionBlock, BlockType.TableSubQuery); context.plan.connectBlocks(rightBlock, unionBlock, BlockType.TableSubQuery); // set InsertNode's child with ProjectionNode which is created. insertNode.setChild(projectionNode); return projectionNode; }