@Override public LogicalNode visitTableSubQuery(Context upperContext, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { Context childContext = new Context(plan, upperContext.requiredSet); stack.push(node); LogicalNode child = super.visitTableSubQuery(childContext, plan, block, node, stack); node.setSubQuery(child); stack.pop(); Target [] targets; if (node.hasTargets()) { targets = node.getTargets(); } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet); it.hasNext();) { Target target = it.next(); upperContext.addExpr(target); } for (Iterator<Target> it = upperContext.targetListMgr.getFilteredTargets(upperContext.requiredSet); it.hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); upperContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(projectedTargets.toArray(new Target[projectedTargets.size()])); LogicalPlanner.verifyProjectedFields(block, node); return node; }
@Override public LogicalNode visitTableSubQuery(Context upperContext, LogicalPlan plan, LogicalPlan.QueryBlock block, TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { Context childContext = new Context(plan, upperContext.requiredSet); stack.push(node); LogicalNode child = super.visitTableSubQuery(childContext, plan, block, node, stack); node.setSubQuery(child); stack.pop(); List<Target> targets; if (node.hasTargets()) { targets = node.getTargets(); } else { targets = PlannerUtil.schemaToTargets(node.getOutSchema()); } LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet(); for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet); it.hasNext();) { Target target = it.next(); upperContext.addExpr(target); } for (Iterator<Target> it = upperContext.targetListMgr.getFilteredTargets(upperContext.requiredSet); it.hasNext();) { Target target = it.next(); if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node)) { projectedTargets.add(target); upperContext.targetListMgr.markAsEvaluated(target); } } node.setTargets(new ArrayList<>(projectedTargets)); LogicalPlanner.verifyProjectedFields(block, node); return node; }
private TableSubQueryNode visitCommonTableSubquery(PlanContext context, Stack<Expr> stack, CommonSubquery expr) throws TajoException { QueryBlock currentBlock = context.queryBlock; QueryBlock childBlock = context.plan.getBlock(context.plan.getBlockNameByExpr(expr.getSubQuery())); context.plan.connectBlocks(childBlock, currentBlock, BlockType.TableSubQuery); PlanContext newContext = new PlanContext(context, childBlock); context.plan.connectBlocks(childBlock, context.queryBlock, BlockType.TableSubQuery); LogicalNode child = visit(newContext, new Stack<>(), expr.getSubQuery()); TableSubQueryNode subQueryNode = currentBlock.getNodeFromExpr(expr); subQueryNode.setSubQuery(child); setTargetOfTableSubQuery(context, currentBlock, subQueryNode); return subQueryNode; }
private TableSubQueryNode visitCommonTableSubquery(PlanContext context, Stack<Expr> stack, CommonSubquery expr) throws TajoException { QueryBlock currentBlock = context.queryBlock; QueryBlock childBlock = context.plan.getBlock(context.plan.getBlockNameByExpr(expr.getSubQuery())); context.plan.connectBlocks(childBlock, currentBlock, BlockType.TableSubQuery); PlanContext newContext = new PlanContext(context, childBlock); context.plan.connectBlocks(childBlock, context.queryBlock, BlockType.TableSubQuery); LogicalNode child = visit(newContext, new Stack<Expr>(), expr.getSubQuery()); TableSubQueryNode subQueryNode = currentBlock.getNodeFromExpr(expr); subQueryNode.setSubQuery(child); setTargetOfTableSubQuery(context, currentBlock, subQueryNode); return subQueryNode; }
TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitTableSubQuery(context, plan, queryBlock, node, stack); node.setSubQuery(child); for (ExecutionBlock childBlock : context.plan.getChilds(currentBlock.getId())) { TableSubQueryNode copy = PlannerUtil.clone(plan, node); copy.setSubQuery(childBlock.getPlan()); childBlock.setPlan(copy); addedTableSubQueries.add(copy);
private SelectionNode createSelectionParentForNonEquiThetaJoinQuals(LogicalPlan plan, QueryBlock block, Stack<LogicalNode> stack, JoinNode joinNode, List<EvalNode> nonEquiThetaJoinQuals) { SelectionNode selectionNode = plan.createNode(SelectionNode.class); selectionNode.setInSchema(joinNode.getOutSchema()); selectionNode.setOutSchema(joinNode.getOutSchema()); selectionNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(nonEquiThetaJoinQuals)); block.registerNode(selectionNode); LogicalNode parent = stack.peek(); if (parent instanceof UnaryNode) { ((UnaryNode) parent).setChild(selectionNode); } else if (parent instanceof BinaryNode) { BinaryNode binaryParent = (BinaryNode) parent; if (binaryParent.getLeftChild().getPID() == joinNode.getPID()) { binaryParent.setLeftChild(selectionNode); } else if (binaryParent.getRightChild().getPID() == joinNode.getPID()) { binaryParent.setRightChild(selectionNode); } } else if (parent instanceof TableSubQueryNode) { ((TableSubQueryNode) parent).setSubQuery(selectionNode); } selectionNode.setChild(joinNode); return selectionNode; }
private SelectionNode createSelectionParentForNonEquiThetaJoinQuals(LogicalPlan plan, QueryBlock block, Stack<LogicalNode> stack, JoinNode joinNode, List<EvalNode> nonEquiThetaJoinQuals) { SelectionNode selectionNode = plan.createNode(SelectionNode.class); selectionNode.setInSchema(joinNode.getOutSchema()); selectionNode.setOutSchema(joinNode.getOutSchema()); selectionNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(nonEquiThetaJoinQuals)); block.registerNode(selectionNode); LogicalNode parent = stack.peek(); if (parent instanceof UnaryNode) { ((UnaryNode) parent).setChild(selectionNode); } else if (parent instanceof BinaryNode) { BinaryNode binaryParent = (BinaryNode) parent; if (binaryParent.getLeftChild().getPID() == joinNode.getPID()) { binaryParent.setLeftChild(selectionNode); } else if (binaryParent.getRightChild().getPID() == joinNode.getPID()) { binaryParent.setRightChild(selectionNode); } } else if (parent instanceof TableSubQueryNode) { ((TableSubQueryNode) parent).setSubQuery(selectionNode); } selectionNode.setChild(joinNode); return selectionNode; }
case TABLE_SUBQUERY: TableSubQueryNode tableSubQueryNode = (TableSubQueryNode) parentNode; tableSubQueryNode.setSubQuery(child); break; case STORE:
TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitTableSubQuery(context, plan, queryBlock, node, stack); node.setSubQuery(child); for (ExecutionBlock childBlock : context.plan.getChilds(currentBlock.getId())) { TableSubQueryNode copy = PlannerUtil.clone(plan, node); copy.setSubQuery(childBlock.getPlan()); childBlock.setPlan(copy); addedTableSubQueries.add(copy);
case TABLE_SUBQUERY: TableSubQueryNode tableSubQueryNode = (TableSubQueryNode) parentNode; tableSubQueryNode.setSubQuery(child); break; case STORE: