private Scope createScopeForCommonTableExpression(
        Table table, Optional<Scope> scope, WithQuery withQuery) {
      Query query = withQuery.getQuery();
      analysis.registerNamedQuery(table, query);

      // re-alias the fields with the name assigned to the query in the WITH declaration
      RelationType queryDescriptor = analysis.getOutputDescriptor(query);

      List<Field> fields;
      Optional<List<Identifier>> columnNames = withQuery.getColumnNames();
      if (columnNames.isPresent()) {
        // if columns are explicitly aliased -> WITH cte(alias1, alias2 ...)
        checkState(
            columnNames.get().size() == queryDescriptor.getVisibleFieldCount(),
            "mismatched aliases");
        ImmutableList.Builder<Field> fieldBuilder = ImmutableList.builder();
        Iterator<Identifier> aliases = columnNames.get().iterator();
        for (int i = 0; i < queryDescriptor.getAllFieldCount(); i++) {
          Field inputField = queryDescriptor.getFieldByIndex(i);
          if (!inputField.isHidden()) {
            Field field =
                Field.newQualified(
                    QualifiedName.of(table.getName().getSuffix()),
                    Optional.of(aliases.next().getValue()),
                    inputField.getType(),
                    inputField.getColumnCategory(),
                    false,
                    inputField.getOriginTable(),
                    inputField.getOriginColumnName(),
                    inputField.isAliased());
            fieldBuilder.add(field);
            analysis.addSourceColumns(field, analysis.getSourceColumns(inputField));
          }
        }
        fields = fieldBuilder.build();
      } else {
        ImmutableList.Builder<Field> fieldBuilder = ImmutableList.builder();
        for (int i = 0; i < queryDescriptor.getAllFieldCount(); i++) {
          Field inputField = queryDescriptor.getFieldByIndex(i);
          if (!inputField.isHidden()) {
            Field field =
                Field.newQualified(
                    QualifiedName.of(table.getName().getSuffix()),
                    inputField.getName(),
                    inputField.getType(),
                    inputField.getColumnCategory(),
                    false,
                    inputField.getOriginTable(),
                    inputField.getOriginColumnName(),
                    inputField.isAliased());
            fieldBuilder.add(field);
            analysis.addSourceColumns(field, analysis.getSourceColumns(inputField));
          }
        }
        fields = fieldBuilder.build();
      }

      return createAndAssignScope(table, scope, fields);
    }
Check if there is Columns function in expression, and verify they are same if there are multi
Column functions.

@param expression input expression
@return if there is Columns function in expression
@throws SemanticException if there are multi Columns functions but different
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java