public Expression applyLevels(
      boolean isCountStar, Expression expression, String alias, Analysis analysis) {
    analyzeExpressionType(analysis, expression);
    Expression outputExpression = ExpressionAnalyzer.replaceSubTreeWithView(expression, analysis);

    // construct output expression
    // e.g. count(root.sg.d1.s1) -> count(root.sg.*.s1)
    Expression groupedOutputExpression =
        ExpressionAnalyzer.replaceRawPathWithGroupedPath(
            outputExpression,
            rawPathToGroupedPathMap,
            path -> transformPathByLevels(isCountStar, path));
    if (alias != null) {
      checkAliasAndUpdateAliasMap(alias, groupedOutputExpression.toString());
    }

    // update groupedAggregationExpressionToRawExpressionsMap
    Set<Expression> rawAggregationExpressions =
        new HashSet<>(ExpressionAnalyzer.searchAggregationExpressions(expression));
    for (Expression rawAggregationExpression : rawAggregationExpressions) {
      Expression rawOutputAggregationExpression =
          ExpressionAnalyzer.replaceSubTreeWithView(rawAggregationExpression, analysis);
      Expression groupedOutputAggregationExpression =
          ExpressionAnalyzer.replaceRawPathWithGroupedPath(
              rawOutputAggregationExpression,
              rawPathToGroupedPathMap,
              path -> transformPathByLevels(isCountStar, path));
      groupedOutputAggregationExpression = normalizeExpression(groupedOutputAggregationExpression);
      analyzeExpressionType(analysis, groupedOutputAggregationExpression);

      rawAggregationExpression =
          ExpressionAnalyzer.normalizeExpression(rawAggregationExpression, false);
      analyzeExpressionType(analysis, rawAggregationExpression);

      groupedAggregationExpressionToRawExpressionsMap
          .computeIfAbsent(groupedOutputAggregationExpression, key -> new HashSet<>())
          .add(rawAggregationExpression);
    }
    return groupedOutputExpression;
  }
Only used to check whether one alisa is corresponding to only one column. i.e. Different
columns can't have the same alias.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/GroupByLevelHelper.java