**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 (has_window)
        {
            query_analyzer.makeWindowDescriptions(chain.getLastActions());
            query_analyzer.appendWindowFunctionsArguments(chain, only_types || !first_stage);
            
            
            for (const auto & x : chain.getLastActions()->getNamesAndTypesList())
            {
                query_analyzer.columns_after_window.push_back(x);
            }
            
            
            
            for (const auto & [_, w] : query_analyzer.window_descriptions)
            {
                for (const auto & f : w.window_functions)
                {
                    query_analyzer.columns_after_window.push_back(
                        {f.column_name, f.aggregate_function->getReturnType()});
                }
            }
            before_window = chain.getLastActions();
            finalize_chain(chain);
            auto & step = chain.lastStep(query_analyzer.columns_after_window);