presto-main/src/main/java/io/prestosql/sql/planner/SubqueryPlanner.java/SubqueryPlanner/appendCorrelatedJoin
class SubqueryPlanner:    public PlanBuilder appendCorrelatedJoin(PlanBuilder subPlan, PlanBuilder subqueryPlan, Query query, boolean correlationAllowed, CorrelatedJoinNode.Type type, Expression filterCondition)
    {
        PlanNode subqueryNode = subqueryPlan.getRoot();
        Map<NodeRef<Expression>, Expression> correlation = extractCorrelation(subPlan, subqueryNode);
        if (!correlationAllowed && !correlation.isEmpty()) {
            throw semanticException(NOT_SUPPORTED, query, "Correlated subquery in given context is not supported");
        }
        subqueryNode = replaceExpressionsWithSymbols(subqueryNode, correlation);

        return new PlanBuilder(
                subPlan.copyTranslations(),
                new CorrelatedJoinNode(
                        idAllocator.getNextId(),
                        subPlan.getRoot(),
                        subqueryNode,
                        ImmutableList.copyOf(SymbolsExtractor.extractUnique(correlation.values())),
                        type,
                        filterCondition,
                        query));
    }