private static TableSubQueryNode convertTableSubQuery(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.TableSubQueryNode proto = protoNode.getTableSubQuery(); TableSubQueryNode tableSubQuery = new TableSubQueryNode(protoNode.getNodeId()); tableSubQuery.init(proto.getTableName(), nodeMap.get(proto.getChildSeq())); tableSubQuery.setInSchema(convertSchema(protoNode.getInSchema())); if (proto.getTargetsCount() > 0) { tableSubQuery.setTargets(convertTargets(context, evalContext, proto.getTargetsList())); } tableSubQuery.setNameResolveBase(proto.getNameResolveBase()); return tableSubQuery; }
private static TableSubQueryNode convertTableSubQuery(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.TableSubQueryNode proto = protoNode.getTableSubQuery(); TableSubQueryNode tableSubQuery = new TableSubQueryNode(protoNode.getNodeId()); tableSubQuery.init(proto.getTableName(), nodeMap.get(proto.getChildSeq())); tableSubQuery.setInSchema(convertSchema(protoNode.getInSchema())); if (proto.getTargetsCount() > 0) { tableSubQuery.setTargets(convertTargets(context, evalContext, proto.getTargetsList())); } tableSubQuery.setNameResolveBase(proto.getNameResolveBase()); return tableSubQuery; }
@Override public LogicalNode visitSimpleTableSubquery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SimpleTableSubquery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitSimpleTableSubquery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), ctx.generateUniqueSubQueryName()), child); ctx.getQueryBlock().addRelation(node); if (stack.peek().getType() == OpType.InPredicate) { // In-subquery and scalar subquery cannot be the base for name resolution. node.setNameResolveBase(false); } return node; }
@Override public LogicalNode visitSimpleTableSubquery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SimpleTableSubquery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitSimpleTableSubquery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), ctx.generateUniqueSubQueryName()), child); ctx.getQueryBlock().addRelation(node); if (stack.peek().getType() == OpType.InPredicate) { // In-subquery and scalar subquery cannot be the base for name resolution. node.setNameResolveBase(false); } return node; }