**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
{
    auto set_key = PreparedSetKey::forSubquery(*subquery_or_table_name);
    if (prepared_sets.count(set_key))
        return; 
    if (auto set_ptr_from_storage_set = isPlainStorageSetInSubquery(subquery_or_table_name))
    {
        prepared_sets.insert({set_key, set_ptr_from_storage_set});
        return;
    }
    auto interpreter_subquery = interpretSubquery(subquery_or_table_name, context, {}, query_options);
    auto io = interpreter_subquery->execute();
    PullingPipelineExecutor executor(io.pipeline);
    SetPtr set = std::make_shared<Set>(settings.size_limits_for_set, true, context.getSettingsRef().transform_null_in);
    set->setHeader(executor.getHeader());
    Block block;
    while (executor.pull(block))
    {
        
        if (!set->insertFromBlock(block))
            return;
    }
    set->finishInsert();
    prepared_sets[set_key] = std::move(set);
}
SetPtr SelectQueryExpressionAnalyzer::isPlainStorageSetInSubquery(const ASTPtr & subquery_or_table_name)