public void setRoot(LogicalNode blockRoot) { this.rootNode = blockRoot; if (blockRoot instanceof LogicalRootNode) { LogicalRootNode rootNode = (LogicalRootNode) blockRoot; rootType = rootNode.getChild().getType(); } }
@Override public LogicalNode visit(JoinGraphContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalNode node, Stack<LogicalNode> stack) throws TajoException { if (node.getType() != NodeType.TABLE_SUBQUERY) { super.visit(context, plan, block, node, stack); } return node; }
@Override public LogicalNode visit(RelationNodeFinderContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalNode node, Stack<LogicalNode> stack) throws TajoException { if (node.getType() != NodeType.TABLE_SUBQUERY) { super.visit(context, plan, block, node, stack); } if (node instanceof RelationNode) { context.founds.add((RelationNode) node); } return node; }
@Override public LogicalNode visit(RelationNodeFinderContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, LogicalNode node, Stack<LogicalNode> stack) throws TajoException { if (node.getType() != NodeType.TABLE_SUBQUERY) { super.visit(context, plan, block, node, stack); } if (node instanceof RelationNode) { context.founds.add((RelationNode) node); } return node; }
public void unregisterNode(LogicalNode node) { nodeMap.remove(node.getPID()); nodeTypeToNodeMap.remove(node.getType()); queryBlockByPID.remove(node.getPID()); }
@Override public JsonElement serialize(LogicalNode src, Type typeOfSrc, JsonSerializationContext context) { JsonObject json = new JsonObject(); json.addProperty("type", src.getType().name()); json.add("body", context.serialize(src)); return json; } }
public void registerNode(LogicalNode node) { // id -> node nodeMap.put(node.getPID(), node); // So, this is only for filter, groupby, sort, limit, projection, which exists once at a query block. nodeTypeToNodeMap.put(node.getType(), node); queryBlockByPID.put(node.getPID(), this); }
public void unregisterNode(LogicalNode node) { nodeMap.remove(node.getPID()); nodeTypeToNodeMap.remove(node.getType()); queryBlockByPID.remove(node.getPID()); }
public void registerNode(LogicalNode node) { // id -> node nodeMap.put(node.getPID(), node); // So, this is only for filter, groupby, sort, limit, projection, which exists once at a query block. nodeTypeToNodeMap.put(node.getType(), node); queryBlockByPID.put(node.getPID(), this); }
@Override public boolean isEligible(LogicalPlanRewriteRuleContext context) { boolean hbaseMode = "false".equalsIgnoreCase(context.getQueryContext().get(HBaseStorageConstants.INSERT_PUT_MODE, "false")); LogicalRootNode rootNode = context.getPlan().getRootBlock().getRoot(); LogicalNode node = rootNode.getChild(); return hbaseMode && node.getType() == NodeType.CREATE_TABLE || node.getType() == NodeType.INSERT; }
@Override public boolean isEligible(LogicalPlanRewriteRuleContext context) { boolean hbaseMode = "false".equalsIgnoreCase(context.getQueryContext().get(HBaseStorageConstants.INSERT_PUT_MODE, "false")); LogicalRootNode rootNode = context.getPlan().getRootBlock().getRoot(); LogicalNode node = rootNode.getChild(); return hbaseMode && node.getType() == NodeType.CREATE_TABLE || node.getType() == NodeType.INSERT; }
@Override public boolean isEligible(QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) { Stage lastStage = query.getStage(finalExecBlockId); return lastStage.getBlock().getPlan().getType() == NodeType.INSERT; }
@Override public boolean isEligible(QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) { Stage lastStage = query.getStage(finalExecBlockId); NodeType type = lastStage.getBlock().getPlan().getType(); return type != NodeType.CREATE_TABLE && type != NodeType.INSERT; }
@Override public boolean isEligible(QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) { Stage lastStage = query.getStage(finalExecBlockId); return lastStage.getBlock().getPlan().getType() == NodeType.CREATE_INDEX; }
@Override public boolean isEligible(QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) { Stage lastStage = query.getStage(finalExecBlockId); NodeType type = lastStage.getBlock().getPlan().getType(); return type != NodeType.CREATE_TABLE && type != NodeType.INSERT; }
@Override public boolean isEligible(QueryContext queryContext, Query query, ExecutionBlockId finalExecBlockId, Path finalOutputDir) { Stage lastStage = query.getStage(finalExecBlockId); return lastStage.getBlock().getPlan().getType() == NodeType.CREATE_TABLE; }
public static void throwCannotEvaluateException(Projectable projectable, String columnName) throws TajoException { if (projectable instanceof UnaryNode && ((UnaryNode) projectable).getChild().getType() == NodeType.GROUP_BY) { throw makeSyntaxError(columnName + " must appear in the GROUP BY clause or be used in an aggregate function at node (" + projectable.getPID() + ")"); } else { throw makeSyntaxError(String.format("Cannot evaluate the field \"%s\" at node (%d)", columnName, projectable.getPID())); } }
public static String getStoreTableName(LogicalPlan plan) { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); NodeType nodeType = rootNode.getChild().getType(); if (nodeType == NodeType.CREATE_TABLE) { return ((CreateTableNode)rootNode.getChild()).getTableName(); } else if (nodeType == NodeType.INSERT) { return ((InsertNode)rootNode.getChild()).getTableName(); } else { return null; } }
@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()); }
public void prepareTable(LogicalNode node) throws TajoException, IOException { if (node.getType() == NodeType.CREATE_TABLE) { CreateTableNode cNode = (CreateTableNode)node; if (!cNode.isExternal()) { TableMeta tableMeta = new TableMeta(cNode.getStorageType(), cNode.getOptions()); createTable( ((CreateTableNode) node).getUri(), tableMeta, cNode.getTableSchema(), cNode.isExternal(), cNode.isIfNotExists()); } } }