It's ok when i run
 
```sql
with
   (select count(*) from system.clusters) as v1,
   (select count(*) from system.disks) as v2
select v1 as v
union  all
select v2 as v
```
result:
```
v |
--+
14|
 1|
```
,
but when i  wrap it in subquery:

```sql
SELECT v
FROM
  (with
     (select count(*)  from system.clusters) as v1,
     (select count(*) from system.disks) as v2
   select v1 as v
   union  all
   select v2 as v) as a 
```

it raise error:

`SQL Error [47]: ClickHouse exception, code: 47, host: 127.0.0.1, port: 46535; Code: 47, e.displayText() = DB::Exception: Missing columns: 'v2' while processing query: 'SELECT v2 AS v', required columns: 'v2' (version 21.7.3.14 (official build))`
,
in fact ,  if i drop `union all`, it's still ok:

```sql
SELECT v
FROM
  (with
     (select count(*) from system.clusters) as v1,
     (select count(*) from system.disks) as v2
  select v1 as v
) as a 
LIMIT 1000;
```
result:
```
v |
--+
14|
```
seems that it cannot recognize `union all` under `with` clause in subquery (version: 21.7.3.14).

Another way to avoid error is `with` first, like this:
```sql
with
     (select count(*)  from system.clusters) as v1,
     (select count(*) from system.disks) as v2
SELECT v
FROM(
   select v1 as v
   union  all
   select v2 as v) as a 
```

#include <Interpreters/ApplyWithGlobalVisitor.h>
#include <Parsers/ASTSelectQuery.h>
#include <Parsers/ASTSelectWithUnionQuery.h>
#include <Parsers/ASTSelectIntersectExceptQuery.h>
#include <Parsers/ASTWithAlias.h>
namespace DB
{
void ApplyWithGlobalVisitor::visit(ASTSelectQuery & select, const std::map<String, ASTPtr> & exprs, const ASTPtr & with_expression_list)
{
    auto with = select.with();
    if (with)
    {
        std::set<String> current_names;
        for (const auto & child : with->children)
        {
            if (const auto * ast_with_alias = dynamic_cast<const ASTWithAlias *>(child.get()))
                current_names.insert(ast_with_alias->alias);
        }
        for (const auto & with_alias : exprs)
        {
            if (!current_names.contains(with_alias.first))
                with->children.push_back(with_alias.second->clone());
        }
    }
    else
        select.setExpression(ASTSelectQuery::Expression::WITH, with_expression_list->clone());
}
void ApplyWithGlobalVisitor::visit(