**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
{
    LogAST log;
    ActionsVisitor::Data visitor_data(context, settings.size_limits_for_set, subquery_depth,
                                   sourceColumns(), std::move(actions), prepared_sets, subqueries_for_sets,
                                   no_subqueries, true, only_consts, !isRemoteStorage());
    ActionsVisitor(visitor_data, log.stream()).visit(ast);
    actions = visitor_data.getActions();
}
void ExpressionAnalyzer::getRootActionsForHaving(const ASTPtr & ast, bool no_subqueries, ActionsDAGPtr & actions, bool only_consts)
{
    LogAST log;
    ActionsVisitor::Data visitor_data(context, settings.size_limits_for_set, subquery_depth,
                                   sourceColumns(), std::move(actions), prepared_sets, subqueries_for_sets,
                                   no_subqueries, false, only_consts, true);
    ActionsVisitor(visitor_data, log.stream()).visit(ast);
    actions = visitor_data.getActions();
}
bool ExpressionAnalyzer::makeAggregateDescriptions(ActionsDAGPtr & actions)
{
    for (const ASTFunction * node : aggregates())
    {
        AggregateDescription aggregate;
        if (node->arguments) getRootActionsNoMakeSet(node->arguments, true, actions);
        aggregate.column_name = node->getColumnName();
        const ASTs & arguments = node->arguments ? node->arguments->children : ASTs();
        aggregate.argument_names.resize(arguments.size());
        DataTypes types(arguments.size());
        const auto & index = actions->getIndex();
        for (size_t i = 0; i < arguments.size(); ++i)
        {