**Describe the bug**

The query:
```
SELECT
    (current_database = currentDatabase()) AND (type = 0),
    ((current_database = currentDatabase()) AND (type = NULL)) AND (type = NULL) AND ((current_database = currentDatabase()) AND (type = 1048575)) AND (type = NULL) AND (event_date >= yesterday())
FROM system.query_log
ARRAY JOIN ProfileEvents
WHERE ProfileEvents AND (current_database = currentDatabase())
ORDER BY event_time DESC NULLS FIRST
LIMIT 0
```
crashes the server.

Most likely introduced here: #16618
if (getSelectQuery()->window())
    {
        getRootActionsNoMakeSet(getSelectQuery()->window(),
            true , step.actions());
    }
    for (const auto & [_, w] : window_descriptions)
    {
        for (const auto & f : w.window_functions)
        {
            
            
            
            
            getRootActionsNoMakeSet(f.function_node->clone(),
                true , step.actions());
            
            for (const auto & a : f.function_node->arguments->children)
            {
                step.required_output.push_back(a->getColumnName());
            }
        }
        
        for (const auto & c : w.full_sort_description)
        {
            step.required_output.push_back(c.column_name);
        }
    }
}
bool SelectQueryExpressionAnalyzer::appendHaving(ExpressionActionsChain & chain, bool only_types)