public PlanBuilder appendLateralJoin(PlanBuilder subPlan, PlanBuilder subqueryPlan, Query query, boolean correlationAllowed, LateralJoinNode.Type type) { PlanNode subqueryNode = subqueryPlan.getRoot(); Map<Expression, Expression> correlation = extractCorrelation(subPlan, subqueryNode); if (!correlationAllowed && !correlation.isEmpty()) { throw notSupportedException(query, "Correlated subquery in given context"); } subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation); return new PlanBuilder( subPlan.copyTranslations(), new LateralJoinNode( idAllocator.getNextId(), subPlan.getRoot(), subqueryNode, ImmutableList.copyOf(SymbolsExtractor.extractUnique(correlation.values())), type, query), analysis.getParameters()); }
public PlanBuilder appendLateralJoin(PlanBuilder subPlan, PlanBuilder subqueryPlan, Query query, boolean correlationAllowed, LateralJoinNode.Type type) { PlanNode subqueryNode = subqueryPlan.getRoot(); Map<Expression, Expression> correlation = extractCorrelation(subPlan, subqueryNode); if (!correlationAllowed && !correlation.isEmpty()) { throw notSupportedException(query, "Correlated subquery in given context"); } subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation); return new PlanBuilder( subPlan.copyTranslations(), new LateralJoinNode( idAllocator.getNextId(), subPlan.getRoot(), subqueryNode, ImmutableList.copyOf(SymbolsExtractor.extractUnique(correlation.values())), type, query), analysis.getParameters()); }
private PlanBuilder appendApplyNode( PlanBuilder subPlan, Node subquery, PlanNode subqueryNode, Assignments subqueryAssignments, boolean correlationAllowed) { Map<Expression, Expression> correlation = extractCorrelation(subPlan, subqueryNode); if (!correlationAllowed && !correlation.isEmpty()) { throw notSupportedException(subquery, "Correlated subquery in given context"); } subPlan = subPlan.appendProjections(correlation.keySet(), symbolAllocator, idAllocator); subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation); TranslationMap translations = subPlan.copyTranslations(); PlanNode root = subPlan.getRoot(); return new PlanBuilder(translations, new ApplyNode(idAllocator.getNextId(), root, subqueryNode, subqueryAssignments, ImmutableList.copyOf(SymbolsExtractor.extractUnique(correlation.values())), subquery), analysis.getParameters()); }
private PlanBuilder appendApplyNode( PlanBuilder subPlan, Node subquery, PlanNode subqueryNode, Assignments subqueryAssignments, boolean correlationAllowed) { Map<Expression, Expression> correlation = extractCorrelation(subPlan, subqueryNode); if (!correlationAllowed && !correlation.isEmpty()) { throw notSupportedException(subquery, "Correlated subquery in given context"); } subPlan = subPlan.appendProjections(correlation.keySet(), symbolAllocator, idAllocator); subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation); TranslationMap translations = subPlan.copyTranslations(); PlanNode root = subPlan.getRoot(); return new PlanBuilder(translations, new ApplyNode(idAllocator.getNextId(), root, subqueryNode, subqueryAssignments, ImmutableList.copyOf(SymbolsExtractor.extractUnique(correlation.values())), subquery), analysis.getParameters()); }