```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".

{
            LOG_DEBUG(log, "Will use no data on this replica because parallel replicas processing has been requested"
                " (the setting 'max_parallel_replicas') but the table does not support sampling and this replica is not the first.");
            return std::make_unique<QueryPlan>();
        }
        sampling.use_sampling = relative_sample_size > 0 || (settings.parallel_replicas_count > 1 && data.supportsSampling());
        bool no_data = false;   
        if (sampling.use_sampling)
        {
            if (sample_factor_column_queried && relative_sample_size != RelativeSize(0))
                used_sample_factor = 1.0 / boost::rational_cast<Float64>(relative_sample_size);
            RelativeSize size_of_universum = 0;
            const auto & sampling_key = metadata_snapshot->getSamplingKey();
            DataTypePtr sampling_column_type = sampling_key.data_types[0];
            if (sampling_key.data_types.size() == 1)
            {
                if (typeid_cast<const DataTypeUInt64 *>(sampling_column_type.get()))
                    size_of_universum = RelativeSize(std::numeric_limits<UInt64>::max()) + RelativeSize(1);
                else if (typeid_cast<const DataTypeUInt32 *>(sampling_column_type.get()))
                    size_of_universum = RelativeSize(std::numeric_limits<UInt32>::max()) + RelativeSize(1);
                else if (typeid_cast<const DataTypeUInt16 *>(sampling_column_type.get()))
                    size_of_universum = RelativeSize(std::numeric_limits<UInt16>::max()) + RelativeSize(1);
                else if (typeid_cast<const DataTypeUInt8 *>(sampling_column_type.get()))
                    size_of_universum = RelativeSize(std::numeric_limits<UInt8>::max()) + RelativeSize(1);
            }
            if (size_of_universum == RelativeSize(0))
                throw Exception(
                    "Invalid sampling column type in storage parameters: " + sampling_column_type->getName()
                        + ". Must be one unsigned integer type",
                    ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER);