**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.
```

{
    ASTPtr with = select.with();
    if (!with)
        return;
    for (auto & child : with->children)
        if (auto * ast_with_alias = dynamic_cast<ASTWithAlias *>(child.get()))
            ast_with_alias->prefer_alias_to_column_name = true;
}
template <typename T>
void QueryAliasesMatcher<T>::visit(const ASTArrayJoin &, const ASTPtr & ast, Data & data)
{
    visitOther(ast, data);
    std::vector<ASTPtr> grand_children;
    for (auto & child1 : ast->children)
        for (auto & child2 : child1->children)
            for (auto & child3 : child2->children)
                grand_children.push_back(child3);
    
    for (auto & child : grand_children)
        Visitor(data).visit(child);
}
template <typename T>
void QueryAliasesMatcher<T>::visit(const ASTSubquery & const_subquery, const ASTPtr & ast, Data & data)