@Override
  public Result apply(ApplyNode applyNode, Captures captures, Context context) {
    Set<Symbol> subquerySymbols = extractUnique(applyNode.getSubquery(), context.getLookup());
    List<Symbol> newCorrelation =
        applyNode.getCorrelation().stream()
            .filter(subquerySymbols::contains)
            .collect(toImmutableList());

    if (newCorrelation.size() < applyNode.getCorrelation().size()) {
      return Result.ofPlanNode(
          new ApplyNode(
              applyNode.getPlanNodeId(),
              applyNode.getInput(),
              applyNode.getSubquery(),
              applyNode.getSubqueryAssignments(),
              newCorrelation,
              applyNode.getOriginSubquery()));
    }

    return Result.empty();
  }
This rule updates ApplyNode's correlation list. A symbol can be removed from the correlation list
if it is not referenced by the subquery node. Note: This rule does not restrict ApplyNode's
children outputs. It requires additional information about context (symbols required by the outer
plan) and is done in PruneApplyColumns rule.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/iterative/rule/PruneApplyCorrelation.java