@Override public LogicalNode visitInsert(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); visit(context, plan, block, node.getChild(), stack); stack.pop(); return node; } }
@Override public RESULT visitInsert(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getChild(), stack); stack.pop(); return result; }
@Override public LogicalNode visitInsert(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); visit(context, plan, block, node.getChild(), stack); stack.pop(); return node; } }
@Override public RESULT visitInsert(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, InsertNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getChild(), stack); stack.pop(); return result; }
@Override public void preOrder(LogicalNodeVisitor visitor) { getChild().preOrder(visitor); visitor.visit(this); }
@Override public void postOrder(LogicalNodeVisitor visitor) { visitor.visit(this); getChild().postOrder(visitor); }
@Override public void preOrder(LogicalNodeVisitor visitor) { getChild().preOrder(visitor); visitor.visit(this); }
@Override public void postOrder(LogicalNodeVisitor visitor) { visitor.visit(this); getChild().postOrder(visitor); }
throws IOException { EvalExprExec evalExprExec = new EvalExprExec(taskAttemptContext, (EvalExprNode) insertNode.getChild()); InsertRowsExec exec = new InsertRowsExec(taskAttemptContext, insertNode, evalExprExec);
throws IOException { EvalExprExec evalExprExec = new EvalExprExec(taskAttemptContext, (EvalExprNode) insertNode.getChild()); InsertRowsExec exec = new InsertRowsExec(taskAttemptContext, insertNode, evalExprExec);
LogicalNode child = insertNode.getChild();
LogicalNode child = insertNode.getChild();
private void verifyInsertTableSchema(VerificationState state, LogicalPlan plan) { String dataFormat = PlannerUtil.getDataFormat(plan); if (dataFormat != null) { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); if (rootNode.getChild().getType() == NodeType.INSERT) { try { TableDesc tableDesc = PlannerUtil.getTableDesc(catalog, rootNode.getChild()); InsertNode iNode = rootNode.getChild(); Schema outSchema = iNode.getChild().getOutSchema(); TablespaceManager.get(tableDesc.getUri()).verifySchemaToWrite(tableDesc, outSchema); } catch (TajoException t) { state.addVerification(t); } catch (TajoRuntimeException t) { state.addVerification(t); } catch (Throwable t) { state.addVerification(SyntaxErrorUtil.makeSyntaxError(t.getMessage())); } } } } }
private void verifyInsertTableSchema(VerificationState state, LogicalPlan plan) { String dataFormat = PlannerUtil.getDataFormat(plan); if (dataFormat != null) { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); if (rootNode.getChild().getType() == NodeType.INSERT) { try { TableDesc tableDesc = PlannerUtil.getTableDesc(catalog, rootNode.getChild()); InsertNode iNode = rootNode.getChild(); Schema outSchema = iNode.getChild().getOutSchema(); TablespaceManager.get(tableDesc.getUri()).verifySchemaToWrite(tableDesc, outSchema); } catch (TajoException t) { state.addVerification(t); } catch (TajoRuntimeException t) { state.addVerification(t); } catch (Throwable t) { state.addVerification(SyntaxErrorUtil.makeSyntaxError(t.getMessage())); } } } } }
@Test public final void testInsertInto6() throws TajoException { QueryContext qc = createQueryContext(); Expr expr = sqlAnalyzer.parse(insertStatements[6]); LogicalPlan plan = planner.createPlan(qc, expr); assertEquals(1, plan.getQueryBlocks().size()); InsertNode insertNode = getInsertNode(plan); ProjectionNode subquery = insertNode.getChild(); List<Target> targets = subquery.getTargets(); // targets MUST be manager, NULL as empid, deptname assertEquals(targets.get(0).getNamedColumn().getQualifiedName(), "default.dept.manager"); assertEquals(targets.get(1).getAlias(), "empid"); assertEquals(targets.get(1).getEvalTree().getType(), EvalType.CONST); assertEquals(targets.get(2).getNamedColumn().getQualifiedName(), "default.dept.deptname"); }
taskAttemptContext.setOutputPath(new Path(finalOutputUri)); EvalExprExec evalExprExec = new EvalExprExec(taskAttemptContext, (EvalExprNode) insertNode.getChild()); InsertRowsExec exec = new InsertRowsExec(taskAttemptContext, insertNode, evalExprExec);
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; }