
```
select *
from (
select 'table' as table, toInt64(10) as rows, toInt64(101) as elements
union all
select 'another table' as table, toInt64(0) as rows, toInt64(0) as elements
)
where rows - elements <> 0

DB::Exception: Block structure mismatch in Pipe::unitePipes stream: different number of columns:
table String String(size = 0), rows Int64 Int64(size = 0), elements Int64 Int64(size = 0)
table String String(size = 0), rows Int64 Int64(size = 0), elements Int64 Int64(size = 0), dummy UInt8 UInt8(size = 0) (version 21.5.3.1 (official build))
```
{
    std::unordered_map<const Node *, ColumnWithTypeAndName> node_to_column;
    std::set<size_t> pos_to_remove;
    {
        std::unordered_map<std::string_view, std::list<size_t>> input_positions;
        for (size_t pos = 0; pos < inputs.size(); ++pos)
            input_positions[inputs[pos]->result_name].emplace_back(pos);
        for (size_t pos = 0; pos < header.columns(); ++pos)
        {
            const auto & col = header.getByPosition(pos);
            auto it = input_positions.find(col.name);
            if (it != input_positions.end() && !it->second.empty())
            {
                auto & list = it->second;
                pos_to_remove.insert(pos);
                node_to_column[inputs[list.front()]] = std::move(col);
                list.pop_front();
            }
        }
    }
    ColumnsWithTypeAndName result_columns;
    result_columns.reserve(index.size());
    struct Frame
    {
        const Node * node = nullptr;
        size_t next_child = 0;
    };
    {