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

    return plan.accept(
        new Rewriter(),
        new Context(
            context.getQueryContext().getQueryId(),
            context.getMetadata(),
            context.sessionInfo(),
            context.getSymbolAllocator()));
  }
<b>Optimization phase:</b> Logical plan planning.

<p>The Aggregation may be pushed down to the DeviceTableScanNode, so that we can make use of
statistics.

<p>Attention: This optimizer depends on {@link UnaliasSymbolReferences}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushAggregationIntoTableScan.java