presto-main/src/main/java/io/prestosql/sql/planner/optimizations/CheckSubqueryNodesAreRewritten.java/CheckSubqueryNodesAreRewritten/optimize
class CheckSubqueryNodesAreRewritten:    @Override
    public PlanNode optimize(PlanNode plan, Session session, TypeProvider types, SymbolAllocator symbolAllocator, PlanNodeIdAllocator idAllocator, WarningCollector warningCollector)
    {
        searchFrom(plan).where(ApplyNode.class::isInstance)
                .findFirst()
                .ifPresent(node -> {
                    ApplyNode applyNode = (ApplyNode) node;
                    throw error(applyNode.getCorrelation(), applyNode.getOriginSubquery());
                });

        searchFrom(plan).where(CorrelatedJoinNode.class::isInstance)
                .findFirst()
                .ifPresent(node -> {
                    CorrelatedJoinNode correlatedJoinNode = (CorrelatedJoinNode) node;
                    throw error(correlatedJoinNode.getCorrelation(), correlatedJoinNode.getOriginSubquery());
                });

        return plan;
    }