(you don't have to strictly follow this form)

**Describe the bug**
A link to the report: https://s3.amazonaws.com/clickhouse-test-reports/35466/d81c58b5d9be45ac69c3859b5cbe97080711f6d9/fuzzer_astfuzzerubsan,actions//report.html
The commit: https://github.com/ClickHouse/ClickHouse/commit/d81c58b5d9be45ac69c3859b5cbe97080711f6d9
&& processing_stage == QueryProcessingStage::FetchColumns
        && query_analyzer->hasAggregation()
        && (query_analyzer->aggregates().size() == 1)
        && typeid_cast<const AggregateFunctionCount *>(query_analyzer->aggregates()[0].function.get());
    if (optimize_trivial_count)
    {
        const auto & desc = query_analyzer->aggregates()[0];
        const auto & func = desc.function;
        std::optional<UInt64> num_rows{};
        if (!query.prewhere() && !query.where())
        {
            num_rows = storage->totalRows(settings);
        }
        else 
        {
            SelectQueryInfo temp_query_info;
            temp_query_info.query = query_ptr;
            temp_query_info.syntax_analyzer_result = syntax_analyzer_result;
            temp_query_info.sets = query_analyzer->getPreparedSets();
            num_rows = storage->totalRowsByPartitionPredicate(temp_query_info, context);
        }
        if (num_rows)
        {
            const AggregateFunctionCount & agg_count = static_cast<const AggregateFunctionCount &>(*func);
            
            std::vector<char> state(agg_count.sizeOfData());
            AggregateDataPtr place = state.data();
            agg_count.create(place);
            SCOPE_EXIT_MEMORY_SAFE(agg_count.destroy(place));
            agg_count.set(place, *num_rows);