block.registerNode(selectionNode); projectionNode.setChild(selectionNode); selectionNode.setChild(childNode);
block.registerNode(selectionNode); projectionNode.setChild(selectionNode); selectionNode.setChild(childNode);
private static ProjectionNode convertProjection(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.ProjectionNode projectionProto = protoNode.getProjection(); ProjectionNode projectionNode = new ProjectionNode(protoNode.getNodeId()); projectionNode.init(projectionProto.getDistinct(), convertTargets(context, evalContext, projectionProto.getTargetsList())); projectionNode.setChild(nodeMap.get(projectionProto.getChildSeq())); projectionNode.setInSchema(convertSchema(protoNode.getInSchema())); projectionNode.setOutSchema(convertSchema(protoNode.getOutSchema())); return projectionNode; }
@Override public LogicalNode visitProjection(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitProjection(context, plan, block, node, stack); ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID()); if (child.getType() == NodeType.TABLE_SUBQUERY && ((TableSubQueryNode)child).getSubQuery().getType() == NodeType.UNION) { MasterPlan masterPlan = context.plan; for (DataChannel dataChannel : masterPlan.getIncomingChannels(execBlock.getId())) { dataChannel.setDataFormat(finalOutputDataFormat); ExecutionBlock subBlock = masterPlan.getExecBlock(dataChannel.getSrcId()); ProjectionNode copy = PlannerUtil.clone(plan, node); copy.setChild(subBlock.getPlan()); subBlock.setPlan(copy); } execBlock.setPlan(null); } else { node.setChild(execBlock.getPlan()); node.setInSchema(execBlock.getPlan().getOutSchema()); execBlock.setPlan(node); } context.execBlockMap.put(node.getPID(), execBlock); return node; }
@Override public LogicalNode visitProjection(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitProjection(context, plan, block, node, stack); ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID()); if (child.getType() == NodeType.TABLE_SUBQUERY && ((TableSubQueryNode)child).getSubQuery().getType() == NodeType.UNION) { MasterPlan masterPlan = context.plan; for (DataChannel dataChannel : masterPlan.getIncomingChannels(execBlock.getId())) { dataChannel.setDataFormat(finalOutputDataFormat); ExecutionBlock subBlock = masterPlan.getExecBlock(dataChannel.getSrcId()); ProjectionNode copy = PlannerUtil.clone(plan, node); copy.setChild(subBlock.getPlan()); subBlock.setPlan(copy); } execBlock.setPlan(null); } else { node.setChild(execBlock.getPlan()); node.setInSchema(execBlock.getPlan().getOutSchema()); execBlock.setPlan(node); } context.execBlockMap.put(node.getPID(), execBlock); return node; }
private static ProjectionNode convertProjection(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.ProjectionNode projectionProto = protoNode.getProjection(); ProjectionNode projectionNode = new ProjectionNode(protoNode.getNodeId()); projectionNode.init(projectionProto.getDistinct(), convertTargets(context, evalContext, projectionProto.getTargetsList())); projectionNode.setChild(nodeMap.get(projectionProto.getChildSeq())); projectionNode.setInSchema(convertSchema(protoNode.getInSchema())); projectionNode.setOutSchema(convertSchema(protoNode.getOutSchema())); return projectionNode; }
private void insertDistinctOperator(LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode projectionNode, LogicalNode child) throws TajoException { if (projectionNode.getChild().getType() != NodeType.GROUP_BY) { Schema outSchema = projectionNode.getOutSchema(); GroupbyNode dupRemoval = plan.createNode(GroupbyNode.class); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray()); block.registerNode(dupRemoval); block.setAggregationRequire(); projectionNode.setChild(dupRemoval); projectionNode.setInSchema(dupRemoval.getOutSchema()); } }
private void insertDistinctOperator(LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode projectionNode, LogicalNode child) throws TajoException { if (projectionNode.getChild().getType() != NodeType.GROUP_BY) { Schema outSchema = projectionNode.getOutSchema(); GroupbyNode dupRemoval = plan.createNode(GroupbyNode.class); dupRemoval.setChild(child); dupRemoval.setInSchema(projectionNode.getInSchema()); dupRemoval.setTargets(PlannerUtil.schemaToTargets(outSchema)); dupRemoval.setGroupingColumns(outSchema.toArray()); block.registerNode(dupRemoval); block.setAggregationRequire(); projectionNode.setChild(dupRemoval); projectionNode.setInSchema(dupRemoval.getOutSchema()); } }
projectionNode.setChild(child); projectionNode.setInSchema(child.getOutSchema()); projectionNode.setOutSchema(PlannerUtil.targetToSchema(targets));
projectionNode.setChild(child); projectionNode.setInSchema(child.getOutSchema()); projectionNode.setOutSchema(PlannerUtil.targetToSchema(targets));
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; }
setOpProjectionNode.setInSchema(setOpSchema); setOpProjectionNode.setTargets(setOpTarget); setOpProjectionNode.setChild(setOpGroupbyNode); currentBlock.registerNode(setOpProjectionNode);
setOpProjectionNode.setInSchema(setOpSchema); setOpProjectionNode.setTargets(setOpTarget); setOpProjectionNode.setChild(setOpGroupbyNode); currentBlock.registerNode(setOpProjectionNode);