@Override
  public PlanNode optimize(PlanNode plan, PlanOptimizer.Context context) {
    if (!context.getAnalysis().isQuery() || !context.getAnalysis().containsAggregationQuery()) {
      return plan;
    }

    return plan.accept(new Rewriter(), null);
  }
<b>Optimization phase:</b> Logical plan planning.

<p>Calculate the preGroupedSymbols in {@link AggregationNode}, used in {@link
AggregationNode#isStreamable()}.

<p>Attention: This optimizer should be used before optimizer of {@link
PushAggregationIntoTableScan}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/TransformAggregationToStreamable.java