public Analysis analyze(Statement statement) {
    long startTime = System.nanoTime();
    Analysis analysis =
        new AnalyzeVisitor(partitionFetcher, schemaFetcher).process(statement, context);
    if (context.getSession() != null) {
      // for test compatibility
      analysis.setDatabaseName(context.getDatabaseName().orElse(null));
    }

    if (statement.isQuery()) {
      long analyzeCost =
          System.nanoTime()
              - startTime
              - context.getFetchSchemaCost()
              - context.getFetchPartitionCost();
      QueryPlanCostMetricSet.getInstance().recordTreePlanCost(ANALYZER, analyzeCost);
      context.setAnalyzeCost(analyzeCost);
    }
    return analysis;
  }
Analyze the statement and generate Analysis.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/Analyzer.java