```sql
DROP TABLE IF EXISTS tp;

create table tp (d1 Int32, d2 Int32, eventcnt Int64,
projection p (select sum(eventcnt), d1 group by d1)) 
engine = SummingMergeTree order by (d1, d2);

set allow_experimental_projection_optimization = 1, force_optimize_projection = 1;

select sum(eventcnt) eventcnt, d1
from tp
group by d1;

DB::Exception: No projection is used when allow_experimental_projection_optimization = 1.

```

The exception message is also incorrect, should be "when force_optimize_projection = 1".

if (metadata_snapshot_base->hasPartitionKey())
        {
            const auto & partition_key = metadata_snapshot_base->getPartitionKey();
            auto minmax_columns_names = data.getMinMaxColumnsNames(partition_key);
            minmax_columns_types = data.getMinMaxColumnsTypes(partition_key);
            minmax_idx_condition.emplace(
                query_info, context, minmax_columns_names, data.getMinMaxExpr(partition_key, ExpressionActionsSettings::fromContext(context)));
            partition_pruner.emplace(metadata_snapshot_base, query_info, context, false );
            if (settings.force_index_by_date && (minmax_idx_condition->alwaysUnknownOrTrue() && partition_pruner->isUseless()))
            {
                String msg = "Neither MinMax index by columns (";
                bool first = true;
                for (const String & col : minmax_columns_names)
                {
                    if (first)
                        first = false;
                    else
                        msg += ", ";
                    msg += col;
                }
                msg += ") nor partition expr is used and setting 'force_index_by_date' is set";
                throw Exception(msg, ErrorCodes::INDEX_NOT_USED);
            }
        }
        PartFilterCounters part_filter_counters;
        if (query_context->getSettingsRef().allow_experimental_query_deduplication)
            selectPartsToReadWithUUIDFilter(
                parts,
                part_values,
                data.getPinnedPartUUIDs(),