public RelationType withAlias(String relationAlias, List<String> columnAliases) {
    if (columnAliases != null) {
      checkArgument(
          columnAliases.size() == visibleFields.size(),
          "Column alias list has %s entries but '%s' has %s columns available",
          columnAliases.size(),
          relationAlias,
          visibleFields.size());
    }

    int aliasIndex = 0;
    ImmutableList.Builder<Field> fieldsBuilder = ImmutableList.builder();
    for (Field field : allFields) {
      Optional<String> columnAlias = field.getName();
      if (columnAliases == null) {
        fieldsBuilder.add(
            Field.newQualified(
                QualifiedName.of(relationAlias),
                columnAlias,
                field.getType(),
                field.getColumnCategory(),
                field.isHidden(),
                field.getOriginTable(),
                field.getOriginColumnName(),
                field.isAliased()));
      } else if (!field.isHidden()) {
        // hidden fields are not exposed when there are column aliases
        columnAlias = Optional.of(columnAliases.get(aliasIndex));
        aliasIndex++;
        fieldsBuilder.add(
            Field.newQualified(
                QualifiedName.of(relationAlias),
                columnAlias,
                field.getType(),
                field.getColumnCategory(),
                false,
                field.getOriginTable(),
                field.getOriginColumnName(),
                field.isAliased()));
      }
    }

    return new RelationType(fieldsBuilder.build());
  }
Creates a new tuple descriptor with the relation, and, optionally, the columns aliased.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/RelationType.java