```
CREATE TABLE t (x UInt8, PROJECTION p (SELECT x GROUP BY x)) ENGINE = MergeTree ORDER BY ();
INSERT INTO t VALUES (0);

SET group_by_overflow_mode = 'any', max_rows_to_group_by = 1000, totals_mode = 'after_having_auto';
SELECT x FROM t GROUP BY x WITH TOTALS;
```
ContextPtr query_context, const StorageSnapshotPtr & storage_snapshot, SelectQueryInfo & query_info) const
{
    const auto & metadata_snapshot = storage_snapshot->metadata;
    const auto & settings = query_context->getSettingsRef();
    
    if (!query_info.syntax_analyzer_result)
        return std::nullopt;
    if (!settings.allow_experimental_projection_optimization || query_info.ignore_projections || query_info.is_projection_query
        || settings.aggregate_functions_null_for_empty )
        return std::nullopt;
    
    if (settings.parallel_replicas_count > 1 || settings.max_parallel_replicas > 1)
        return std::nullopt;
    auto query_ptr = query_info.original_query;
    auto * select_query = query_ptr->as<ASTSelectQuery>();
    if (!select_query)
        return std::nullopt;
    
    if (select_query->final())
        return std::nullopt;
    
    if (select_query->sampleSize())
        return std::nullopt;
    
    if (settings.allow_experimental_query_deduplication)
        return std::nullopt;
    
    if (select_query->arrayJoinExpressionList().first)
        return std::nullopt;