/** * Most update queries require only the updates to the catalog information, * but some queries such as "CREATE INDEX" or CTAS requires distributed execution on multiple cluster nodes. * This function checks whether the given DDL plan requires distributed execution or not. * @param node the root node of a query plan * @return Return true if the input query plan requires distributed execution. Otherwise, return false. */ public static boolean isDistExecDDL(LogicalNode node) { LogicalNode baseNode = node; if (node instanceof LogicalRootNode) { baseNode = ((LogicalRootNode) node).getChild(); } NodeType type = baseNode.getType(); return type == NodeType.CREATE_INDEX && !((CreateIndexNode)baseNode).isExternal() || type == NodeType.CREATE_TABLE && ((CreateTableNode)baseNode).hasSubQuery(); }
/** * Most update queries require only the updates to the catalog information, * but some queries such as "CREATE INDEX" or CTAS requires distributed execution on multiple cluster nodes. * This function checks whether the given DDL plan requires distributed execution or not. * @param node the root node of a query plan * @return Return true if the input query plan requires distributed execution. Otherwise, return false. */ public static boolean isDistExecDDL(LogicalNode node) { LogicalNode baseNode = node; if (node instanceof LogicalRootNode) { baseNode = ((LogicalRootNode) node).getChild(); } NodeType type = baseNode.getType(); return type == NodeType.CREATE_INDEX && !((CreateIndexNode)baseNode).isExternal() || type == NodeType.CREATE_TABLE && ((CreateTableNode)baseNode).hasSubQuery(); }
@Override public String toString() { return "CreateIndex (indexName=" + indexMeta.getIndexName() + ", indexPath=" + indexMeta.getIndexPath() + ", type=" + indexMeta.getIndexMethod().name() + ", isUnique=" + indexMeta.isUnique() + ", " + getSortSpecString() + ", isExternal=" + isExternal() + ")"; }
@Override public String toString() { return "CreateIndex (indexName=" + indexMeta.getIndexName() + ", indexPath=" + indexMeta.getIndexPath() + ", type=" + indexMeta.getIndexMethod().name() + ", isUnique=" + indexMeta.isUnique() + ", " + getSortSpecString() + ", isExternal=" + isExternal() + ")"; }
@Override public LogicalNode visitCreateIndex(SerializeContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, CreateIndexNode node, Stack<LogicalNode> stack) throws TajoException { super.visitCreateIndex(context, plan, block, node, new Stack<>()); PlanProto.CreateIndexNode.Builder createIndexBuilder = PlanProto.CreateIndexNode.newBuilder(); int [] childIds = registerGetChildIds(context, node); createIndexBuilder.setChildSeq(childIds[0]); createIndexBuilder.setIndexName(node.getIndexName()); createIndexBuilder.setIndexMethod(node.getIndexMethod()); createIndexBuilder.setIndexPath(node.getIndexPath().toString()); for (SortSpec sortSpec : node.getKeySortSpecs()) { createIndexBuilder.addKeySortSpecs(sortSpec.getProto()); } createIndexBuilder.setTargetRelationSchema(node.getTargetRelationSchema().getProto()); createIndexBuilder.setIsUnique(node.isUnique()); createIndexBuilder.setIsClustered(node.isClustered()); if (node.hasOptions()) { createIndexBuilder.setIndexProperties(node.getOptions().getProto()); } createIndexBuilder.setIsExternal(node.isExternal()); PlanProto.LogicalNode.Builder nodeBuilder = createNodeBuilder(context, node); nodeBuilder.setCreateIndex(createIndexBuilder); context.treeBuilder.addNodes(nodeBuilder); return node; }
@Override public LogicalNode visitCreateIndex(SerializeContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, CreateIndexNode node, Stack<LogicalNode> stack) throws TajoException { super.visitCreateIndex(context, plan, block, node, new Stack<LogicalNode>()); PlanProto.CreateIndexNode.Builder createIndexBuilder = PlanProto.CreateIndexNode.newBuilder(); int [] childIds = registerGetChildIds(context, node); createIndexBuilder.setChildSeq(childIds[0]); createIndexBuilder.setIndexName(node.getIndexName()); createIndexBuilder.setIndexMethod(node.getIndexMethod()); createIndexBuilder.setIndexPath(node.getIndexPath().toString()); for (SortSpec sortSpec : node.getKeySortSpecs()) { createIndexBuilder.addKeySortSpecs(sortSpec.getProto()); } createIndexBuilder.setTargetRelationSchema(node.getTargetRelationSchema().getProto()); createIndexBuilder.setIsUnique(node.isUnique()); createIndexBuilder.setIsClustered(node.isClustered()); if (node.hasOptions()) { createIndexBuilder.setIndexProperties(node.getOptions().getProto()); } createIndexBuilder.setIsExternal(node.isExternal()); PlanProto.LogicalNode.Builder nodeBuilder = createNodeBuilder(context, node); nodeBuilder.setCreateIndex(createIndexBuilder); context.treeBuilder.addNodes(nodeBuilder); return node; }