**How to reproduce**
* Which ClickHouse server version to use
latest master/arcadia
* Non-default settings, if any
```sql
SET prefer_localhost_replica=0
```
(With a local stream the query works fine)
* `CREATE TABLE` statements for all tables involved
```sql
create table "t0" (a Int64, b Int64) engine = MergeTree() partition by a order by a;
create table "dist_t0" (a Int64, b Int64) engine = Distributed(test_shard_localhost, default, t0);
```
* Sample data for all these tables
```sql
insert into t0 values (0, 0);
```
* Queries to run that lead to unexpected result
```sql
di.man.yp-c.yandex.net :) SELECT a / (SELECT sum(number) FROM numbers(10)) FROM dist_t0

SELECT a / 
    (
        SELECT sum(number)
        FROM numbers(10)
    )
FROM dist_t0

Query id: 27b16db2-ad76-403c-8ac1-c03bfb9b0daf


0 rows in set. Elapsed: 0.020 sec. 

Received exception from server (version 21.5.1):
Code: 10. DB::Exception: Received from localhost:9000. DB::Exception: Not found column divide(a, _subquery4) in block. There are only columns: divide(a, CAST(45, 'UInt64')): While executing Remote.
```

{
    auto & aliases = data;
    String alias = ast->tryGetAlias();
    if (!alias.empty())
    {
        if (aliases.count(alias) && ast->getTreeHash() != aliases[alias]->getTreeHash())
            throw Exception(wrongAliasMessage(ast, aliases[alias], alias), ErrorCodes::MULTIPLE_EXPRESSIONS_FOR_ALIAS);
        aliases[alias] = ast;
    }
}
template class QueryAliasesMatcher<QueryAliasesWithSubqueries>;
template class QueryAliasesMatcher<QueryAliasesNoSubqueries>;
}