public void visitDerivedSubquery(SQLBuilderContext ctx, TableSubQueryNode derivedSubquery, Stack<LogicalNode> stack) { ctx.sb.append(" ("); visit(ctx, derivedSubquery.getSubQuery(), stack); ctx.sb.append(" ) ").append(derivedSubquery.getTableName()); }
public void visitDerivedSubquery(SQLBuilderContext ctx, TableSubQueryNode derivedSubquery, Stack<LogicalNode> stack) { ctx.sb.append(" ("); visit(ctx, derivedSubquery.getSubQuery(), stack); ctx.sb.append(" ) ").append(derivedSubquery.getTableName()); }
@Override public RESULT visitTableSubQuery(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock childBlock = plan.getBlock(node.getSubQuery()); result = visit(context, plan, childBlock, childBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getSubQuery(), stack); } stack.pop(); return result; }
@Override public LogicalNode visitTableSubQuery(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { context.depth++; stack.push(node); visit(context, plan, block, node.getSubQuery(), new Stack<LogicalNode>()); stack.pop(); context.depth--; context.add(context.depth, node.getPlanString()); return node; }
public void setLogicalPlan(LogicalNode plan) { this.plan = plan; LogicalNode node = plan; ArrayList<LogicalNode> s = new ArrayList<LogicalNode>(); s.add(node); while (!s.isEmpty()) { node = s.remove(s.size()-1); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; s.add(s.size(), unary.getChild()); } else if (node instanceof BinaryNode) { BinaryNode binary = (BinaryNode) node; s.add(s.size(), binary.getLeftChild()); s.add(s.size(), binary.getRightChild()); } else if (node instanceof ScanNode) { scan.add((ScanNode)node); } else if (node instanceof TableSubQueryNode) { s.add(((TableSubQueryNode) node).getSubQuery()); } } }
@Override public LogicalNode visitTableSubQuery(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { context.depth++; stack.push(node); visit(context, plan, block, node.getSubQuery(), new Stack<>()); stack.pop(); context.depth--; context.add(context.depth, node.getPlanString()); return node; }
@Override public RESULT visitTableSubQuery(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock childBlock = plan.getBlock(node.getSubQuery()); result = visit(context, plan, childBlock, childBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getSubQuery(), stack); } stack.pop(); return result; }
public void setLogicalPlan(LogicalNode plan) { this.plan = plan; LogicalNode node = plan; ArrayList<LogicalNode> s = new ArrayList<>(); s.add(node); while (!s.isEmpty()) { node = s.remove(s.size()-1); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; s.add(s.size(), unary.getChild()); } else if (node instanceof BinaryNode) { BinaryNode binary = (BinaryNode) node; s.add(s.size(), binary.getLeftChild()); s.add(s.size(), binary.getRightChild()); } else if (node instanceof ScanNode) { scan.add((ScanNode)node); } else if (node instanceof TableSubQueryNode) { s.add(((TableSubQueryNode) node).getSubQuery()); } } }
@Override public LogicalNode visitTableSubQuery(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { List<EvalNode> matched = new ArrayList<>(); List<EvalNode> unmatched = new ArrayList<>(); for (EvalNode eval : context.pushingDownFilters) { if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, eval, node)) { matched.add(eval); } else { unmatched.add(eval); } } // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(matched, plan, block, node, node.getSubQuery()); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(node.getSubQuery())); context.setToOrigin(transformedMap); context.addFiltersTobePushed(unmatched); return node; }
@Override public LogicalNode visitTableSubQuery(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); visit(context, plan, null, node.getSubQuery(), stack); stack.pop(); if (node.hasTargets()) { for (Target target : node.getTargets()) { compileIfAbsent(context, node.getLogicalSchema(), target.getEvalTree()); } } return node; }
@Override public LogicalNode visitTableSubQuery(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); visit(context, plan, null, node.getSubQuery(), stack); stack.pop(); if (node.hasTargets()) { for (Target target : node.getTargets()) { compileIfAbsent(context, node.getLogicalSchema(), target.getEvalTree()); } } return node; }
@Override public LogicalNode visitTableSubQuery(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { List<EvalNode> matched = TUtil.newList(); List<EvalNode> unmatched = TUtil.newList(); for (EvalNode eval : context.pushingDownFilters) { if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, eval, node)) { matched.add(eval); } else { unmatched.add(eval); } } // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(matched, plan, block, node, node.getSubQuery()); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(node.getSubQuery())); context.setToOrigin(transformedMap); context.addFiltersTobePushed(unmatched); return node; }
return tableSubQuery.getSubQuery().getType() == NodeType.UNION; return tableSubQuery.getSubQuery().getType() == NodeType.UNION; } else if (childNode.getType() == NodeType.UNION) { // third case return true;
return tableSubQuery.getSubQuery().getType() == NodeType.UNION; return tableSubQuery.getSubQuery().getType() == NodeType.UNION; } else if (childNode.getType() == NodeType.UNION) { // third case return true;
@Override public LogicalNode visitProjection(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitProjection(context, plan, block, node, stack); ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID()); if (child.getType() == NodeType.TABLE_SUBQUERY && ((TableSubQueryNode)child).getSubQuery().getType() == NodeType.UNION) { MasterPlan masterPlan = context.plan; for (DataChannel dataChannel : masterPlan.getIncomingChannels(execBlock.getId())) { dataChannel.setDataFormat(finalOutputDataFormat); ExecutionBlock subBlock = masterPlan.getExecBlock(dataChannel.getSrcId()); ProjectionNode copy = PlannerUtil.clone(plan, node); copy.setChild(subBlock.getPlan()); subBlock.setPlan(copy); } execBlock.setPlan(null); } else { node.setChild(execBlock.getPlan()); node.setInSchema(execBlock.getPlan().getOutSchema()); execBlock.setPlan(node); } context.execBlockMap.put(node.getPID(), execBlock); return node; }
@Override public LogicalNode visitProjection(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, ProjectionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitProjection(context, plan, block, node, stack); ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID()); if (child.getType() == NodeType.TABLE_SUBQUERY && ((TableSubQueryNode)child).getSubQuery().getType() == NodeType.UNION) { MasterPlan masterPlan = context.plan; for (DataChannel dataChannel : masterPlan.getIncomingChannels(execBlock.getId())) { dataChannel.setDataFormat(finalOutputDataFormat); ExecutionBlock subBlock = masterPlan.getExecBlock(dataChannel.getSrcId()); ProjectionNode copy = PlannerUtil.clone(plan, node); copy.setChild(subBlock.getPlan()); subBlock.setPlan(copy); } execBlock.setPlan(null); } else { node.setChild(execBlock.getPlan()); node.setInSchema(execBlock.getPlan().getOutSchema()); execBlock.setPlan(node); } context.execBlockMap.put(node.getPID(), execBlock); return node; }
return computeDescendentVolume(((TableSubQueryNode) node).getSubQuery()); default: throw new IllegalArgumentException("Not RelationNode");
return computeDescendentVolume(((TableSubQueryNode) node).getSubQuery()); default: throw new IllegalArgumentException("Not RelationNode");
((TableSubQueryNode)firstSortNode.getChild()).getSubQuery().getType() == NodeType.UNION) {
((TableSubQueryNode)firstSortNode.getChild()).getSubQuery().getType() == NodeType.UNION) {