
```
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_set<const Node *> visited_nodes;
    std::stack<Node *> stack;
    for (const auto * node : index)
    {
        visited_nodes.insert(node);
        stack.push(const_cast<Node *>(node));
    }
    for (auto & node : nodes)
    {
        
        bool is_array_join = node.type == ActionType::ARRAY_JOIN;
        if (is_array_join && visited_nodes.count(&node) == 0)
        {
            visited_nodes.insert(&node);
            stack.push(&node);
        }
        if (node.type == ActionType::INPUT && !allow_remove_inputs)
            visited_nodes.insert(&node);
    }
    while (!stack.empty())
    {
        auto * node = stack.top();
        stack.pop();
        if (!node->children.empty() && node->column && isColumnConst(*node->column))
        {
            
            node->type = ActionsDAG::ActionType::COLUMN;
            node->children.clear();
        }