@Override
  public Analysis visitCountTimeSeries(
      CountTimeSeriesStatement countTimeSeriesStatement, MPPQueryContext context) {
    Analysis analysis = new Analysis();
    analysis.setRealStatement(countTimeSeriesStatement);

    PathPatternTree patternTree = new PathPatternTree();
    patternTree.appendPathPattern(countTimeSeriesStatement.getPathPattern());

    if (countTimeSeriesStatement.hasTimeCondition()) {
      try {
        boolean hasSchema =
            analyzeTimeseriesRegionScan(
                countTimeSeriesStatement.getTimeCondition(),
                patternTree,
                analysis,
                context,
                countTimeSeriesStatement.getAuthorityScope());
        if (!hasSchema) {
          analysis.setRespDatasetHeader(DatasetHeaderFactory.getCountTimeSeriesHeader());
          return analysis;
        }
      } catch (IllegalPathException e) {
        throw new StatementAnalyzeException(e.getMessage());
      }
    } else {
      SchemaPartition schemaPartitionInfo = partitionFetcher.getSchemaPartition(patternTree);
      analysis.setSchemaPartitionInfo(schemaPartitionInfo);
      Map<Integer, Template> templateMap =
          schemaFetcher.checkAllRelatedTemplate(countTimeSeriesStatement.getPathPattern());
      analysis.setRelatedTemplateInfo(templateMap);
    }
    analysis.setRespDatasetHeader(DatasetHeaderFactory.getCountTimeSeriesHeader());
    return analysis;
  }
Since we fetch raw time series schema without template(The template sequence will be treated
as a normal node, not a device+templateId. This means that all nodes are what we need.). We
can use ALL_MATCH_PATTERN to get result.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java