@Override public LogicalNode visitCreateTable(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock, CreateTableNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitStoreTable(context, plan, queryBlock, node, stack); ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID()); ExecutionBlock newExecBlock = buildStorePlan(context, childBlock, node); context.execBlockMap.put(node.getPID(), newExecBlock); return node; }
@Override public LogicalNode visitCreateTable(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock, CreateTableNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitStoreTable(context, plan, queryBlock, node, stack); ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID()); ExecutionBlock newExecBlock = buildStorePlan(context, childBlock, node); context.execBlockMap.put(node.getPID(), newExecBlock); return node; }
@Test public final void testEnforceForHashBasedColumnPartitionStorePlan() throws IOException, TajoException { Expr context = analyzer.parse(CreateTableAsStmts[2]); LogicalPlan plan = planner.createPlan(defaultContext, context); LogicalRootNode rootNode = (LogicalRootNode) optimizer.optimize(plan); CreateTableNode createTableNode = rootNode.getChild(); Enforcer enforcer = new Enforcer(); enforcer.enforceColumnPartitionAlgorithm(createTableNode.getPID(), ColumnPartitionAlgorithm.HASH_PARTITION); FileFragment[] frags = FileTablespace.splitNG(conf, "default.score", score.getMeta(), new Path(score.getUri()), Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir(TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/testStorePlan"); TaskAttemptContext ctx = new TaskAttemptContext(new QueryContext(conf), LocalTajoTestingUtility.newTaskAttemptId(masterPlan), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(enforcer); ctx.setOutputPath(new Path(workDir, "grouped4")); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf); PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode); exec.close(); assertTrue(exec instanceof HashBasedColPartitionStoreExec); }
@Test public final void testEnforceForSortBasedColumnPartitionStorePlan() throws IOException, TajoException { Expr context = analyzer.parse(CreateTableAsStmts[2]); LogicalPlan plan = planner.createPlan(defaultContext, context); LogicalRootNode rootNode = (LogicalRootNode) optimizer.optimize(plan); CreateTableNode createTableNode = rootNode.getChild(); Enforcer enforcer = new Enforcer(); enforcer.enforceColumnPartitionAlgorithm(createTableNode.getPID(), ColumnPartitionAlgorithm.SORT_PARTITION); FileFragment[] frags = FileTablespace.splitNG(conf, "default.score", score.getMeta(), new Path(score.getUri()), Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir(TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/testStorePlan"); TaskAttemptContext ctx = new TaskAttemptContext(new QueryContext(conf), LocalTajoTestingUtility.newTaskAttemptId(masterPlan), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(enforcer); ctx.setOutputPath(new Path(workDir, "grouped5")); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf); PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode); exec.close(); assertTrue(exec instanceof SortBasedColPartitionStoreExec); }