private PlanBuilder planQuantifiedComparison(
      PlanBuilder subPlan,
      Cluster<QuantifiedComparisonExpression> cluster,
      Analysis.SubqueryAnalysis subqueries) {
    // Plan one of the predicates from the cluster
    QuantifiedComparisonExpression quantifiedComparison = cluster.getRepresentative();

    ComparisonExpression.Operator operator = quantifiedComparison.getOperator();
    QuantifiedComparisonExpression.Quantifier quantifier = quantifiedComparison.getQuantifier();
    Expression value = quantifiedComparison.getValue();
    SubqueryExpression subquery = (SubqueryExpression) quantifiedComparison.getSubquery();

    subPlan = handleSubqueries(subPlan, value, subqueries);

    Symbol output = symbolAllocator.newSymbol(quantifiedComparison, BOOLEAN);

    Analysis.PredicateCoercions predicateCoercions =
        analysis.getPredicateCoercions(quantifiedComparison);

    switch (operator) {
      case EQUAL:
        switch (quantifier) {
          case ALL:
            subPlan =
                planQuantifiedComparison(
                    subPlan, operator, quantifier, value, subquery, output, predicateCoercions);
            return new PlanBuilder(
                subPlan
                    .getTranslations()
                    .withAdditionalMappings(
                        ImmutableMap.of(
                            scopeAwareKey(quantifiedComparison, analysis, subPlan.getScope()),
                            output)),
                subPlan.getRoot());
          case ANY:
          case SOME:
            // A = ANY B <=> A IN B
            subPlan =
                planInPredicate(
                    subPlan, value, subquery, output, quantifiedComparison, predicateCoercions);
            return new PlanBuilder(
                subPlan
                    .getTranslations()
                    .withAdditionalMappings(mapAll(cluster, subPlan.getScope(), output)),
                subPlan.getRoot());
          default:
            throw new IllegalArgumentException();
        }
      case NOT_EQUAL:
        switch (quantifier) {
          case ALL:
            // A <> ALL B <=> !(A IN B)
            return addNegation(
                planInPredicate(
                    subPlan, value, subquery, output, quantifiedComparison, predicateCoercions),
                cluster,
                output);
          case ANY:
          case SOME:
            // A <> ANY B <=> min B <> max B || A <> min B <=> !(min B = max B && A = min B) <=> !(A
            // = ALL B)
            // "A <> ANY B" is equivalent to "NOT (A = ALL B)" so add a rewrite for the initial
            // quantifiedComparison to notAll
            return addNegation(
                planQuantifiedComparison(
                    subPlan,
                    ComparisonExpression.Operator.EQUAL,
                    ALL,
                    value,
                    subquery,
                    output,
                    predicateCoercions),
                cluster,
                output);
          default:
            throw new IllegalArgumentException();
        }
      case LESS_THAN:
      case LESS_THAN_OR_EQUAL:
      case GREATER_THAN:
      case GREATER_THAN_OR_EQUAL:
        subPlan =
            planQuantifiedComparison(
                subPlan, operator, quantifier, value, subquery, output, predicateCoercions);
        return new PlanBuilder(
            subPlan
                .getTranslations()
                .withAdditionalMappings(mapAll(cluster, subPlan.getScope(), output)),
            subPlan.getRoot());
        // Cannot be used with quantified comparison
      case IS_DISTINCT_FROM:
      default:
        throw new IllegalArgumentException(
            format("Unexpected quantified comparison: '%s %s'", operator.getValue(), quantifier));
    }
  }
Plans a correlated subquery for value IN (subQuery)

@param originalExpression the original expression from which the IN predicate was derived. Used
    for subsequent translations.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/SubqueryPlanner.java