def METHOD_NAME(self, select: exp.Select) -> None:
    base = select.args["from"].this.find(exp.Table)
    base_alias = base.alias_or_name
    base_name = exp.table_name(base)
    sources: SourceAggsAndJoins = (
        {} if base_name == self.semantic_name else {base_name: (set(), {})}
    )
    sources.update(self._build_sources(select.selects))
    group = select.args.pop("group", None)
    group_by = group.expressions if group else []
    mapping = {
        remove_namespace(exp.table_name(source.assert_is(exp.Table))): name
        for name, source in Scope(select).references
        if name != base_alias
    }
    explicit_joins = {exp.table_name(join.this): join for join in select.args.pop("joins", [])}
    for i, (name, (aggs, joins)) in enumerate(sources.items()):
        source: exp.Expression = exp.to_table(name)
        table_name = remove_namespace(name)
        if not isinstance(source, exp.Select):
            source = exp.Select().from_(
                exp.alias_(source, table_name, table=True, copy=False), copy=False
            )
        joins.update(explicit_joins)
        query = self._add_joins(source, name, joins, group_by, mapping).select(
            *sorted(aggs, key=str), copy=False
        )
        if not query.selects:
            query.select("*", copy=False)
        if i == 0:
            where = select.args.pop("where", None)
            if where:
                query.where(_replace_table(where.this, table_name, base_alias), copy=False)
            select.from_(query.subquery(base_alias, copy=False), copy=False)
        else:
            select.join(
                query,
                on=[e.eq(_replace_table(e.copy(), table_name, base_alias)) for e in group_by],  # type: ignore
                join_type=self.join_type,
                join_alias=table_name,
                copy=False,
            )
        for node in find_all_in_scope(query, (exp.Column, exp.TableAlias)):
            if isinstance(node, exp.Column):
                if node.table in mapping:
                    node.set("table", exp.to_identifier(mapping[node.table]))
            else:
                if node.name in mapping:
                    node.set("this", exp.to_identifier(mapping[node.name]))
    for expr in select.selects:
        for col in expr.find_all(exp.Column):
            col.set("table", exp.to_identifier(base_alias))