@Override
  public Optional<ConfigPhysicalPlan> visitPipeDeactivateTemplate(
      final PipeDeactivateTemplatePlan pipeDeactivateTemplatePlan, final IoTDBTreePattern pattern) {
    final Map<PartialPath, List<Template>> newTemplateSetInfo =
        pipeDeactivateTemplatePlan.getTemplateSetInfo().entrySet().stream()
            .flatMap(
                entry ->
                    pattern.getIntersection(entry.getKey()).stream()
                        .map(partialPath -> new Pair<>(partialPath, entry.getValue())))
            .collect(
                Collectors.toMap(
                    Pair::getLeft,
                    Pair::getRight,
                    (oldTemplates, newTemplates) ->
                        Stream.of(oldTemplates, newTemplates)
                            .flatMap(Collection::stream)
                            .distinct()
                            .collect(Collectors.toList())));
    return !newTemplateSetInfo.isEmpty()
        ? Optional.of(new PipeDeactivateTemplatePlan(newTemplateSetInfo))
        : Optional.empty();
  }
The {@link PipeConfigPhysicalPlanTreePatternParseVisitor} will transform the schema {@link
ConfigPhysicalPlan}s using {@link IoTDBTreePattern}. Rule:

<p>1. All patterns in the output {@link ConfigPhysicalPlan} will be the intersection of the
original {@link ConfigPhysicalPlan}'s patterns and the given {@link IoTDBTreePattern}.

<p>2. If a pattern does not intersect with the {@link IoTDBTreePattern}, it's dropped.

<p>3. If all the patterns in the {@link ConfigPhysicalPlan} is dropped, the {@link
ConfigPhysicalPlan} is dropped.

<p>4. The output {@link PlanNode} shall be a copied form of the original one because the original
one is used in the {@link PipeConfigRegionWritePlanEvent} in {@link ConfigRegionListeningQueue}.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/extractor/PipeConfigPhysicalPlanTreePatternParseVisitor.java