@Override
  public Result apply(ApplyNode node, Captures captures, Context context) {
    Assignments.Builder assignments = Assignments.builder();
    assignments.putIdentities(node.getInput().getOutputSymbols());

    Cardinality subqueryCardinality = extractCardinality(node.getSubquery(), context.getLookup());
    Expression result;
    if (subqueryCardinality.isEmpty()) {
      result = FALSE_LITERAL;
    } else if (subqueryCardinality.isAtLeastScalar()) {
      result = TRUE_LITERAL;
    } else {
      return Result.empty();
    }

    for (Symbol output : node.getSubqueryAssignments().keySet()) {
      assignments.put(output, result);
    }

    return Result.ofPlanNode(
        new ProjectNode(
            context.getIdAllocator().genPlanNodeId(), node.getInput(), assignments.build()));
  }
Given:

<pre>
- Apply [X.*, e = EXISTS (true)]
  - X
  - S with cardinality >= 1
</pre>

<p>Produces:

<pre>
- Project [X.*, e = true]
  - X
</pre>

<p>Given:

<pre>
- Apply [X.*, e = EXISTS (true)]
  - X
  - S with cardinality = 0
</pre>

<p>Produces:

<pre>
- Project [X.*, e = false]
  - X
</pre>
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/iterative/rule/RemoveRedundantExists.java