```
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;
```
{
            return !part_info.valid_name || !part_info.prefix.empty() || part_info.partition_id != partition_id;
        });
        detached_parts.resize(std::distance(detached_parts.begin(), new_end_it));
        for (const auto & part_info : detached_parts)
        {
            LOG_DEBUG(log, "Found part {}", part_info.dir_name);
            active_parts.add(part_info.dir_name);
        }
        LOG_DEBUG(log, "{} of them are active", active_parts.size());
        
        for (const auto & part_info : detached_parts)
        {
            const String containing_part = active_parts.getContainingPart(part_info.dir_name);
            LOG_DEBUG(log, "Found containing part {} for part {}", containing_part, part_info.dir_name);
            if (!containing_part.empty() && containing_part != part_info.dir_name)
                part_info.disk->moveDirectory(fs::path(relative_data_path) / source_dir / part_info.dir_name,
                    fs::path(relative_data_path) / source_dir / ("inactive_" + part_info.dir_name));
            else
                renamed_parts.addPart(part_info.dir_name, "attaching_" + part_info.dir_name, part_info.disk);
        }
    }
    
    renamed_parts.tryRenameAll();
    
    LOG_DEBUG(log, "Checking {} parts", renamed_parts.old_and_new_names.size());
    MutableDataPartsVector loaded_parts;
    loaded_parts.reserve(renamed_parts.old_and_new_names.size());
    for (const auto & [old_name, new_name, disk] : renamed_parts.old_and_new_names)
    {