```
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;
```
{
    DataPartsVector total_covered_parts;
    if (!isEmpty())
    {
        auto settings = data.getSettings();
        auto parts_lock = acquired_parts_lock ? MergeTreeData::DataPartsLock() : data.lockParts();
        auto * owing_parts_lock = acquired_parts_lock ? acquired_parts_lock : &parts_lock;
        for (const auto & part : precommitted_parts)
            if (part->getDataPartStorage().hasActiveTransaction())
                part->getDataPartStorage().commitTransaction();
        if (txn)
            for (const auto & part : precommitted_parts)
            {
                DataPartPtr covering_part;
                DataPartsVector covered_active_parts = data.getActivePartsToReplace(part->info, part->name, covering_part, *owing_parts_lock);
                
                
                
                DataPartsVector covered_outdated_parts = data.getCoveredOutdatedParts(part, *owing_parts_lock);
                LOG_TEST(data.log, "Got {} oudated parts covered by {} (TID {} CSN {}): {}",
                         covered_outdated_parts.size(), part->getNameWithState(), txn->tid, txn->getSnapshot(), fmt::join(getPartsNames(covered_outdated_parts), ", "));
                data.filterVisibleDataParts(covered_outdated_parts, txn->getSnapshot(), txn->tid);
                DataPartsVector covered_parts;
                covered_parts.reserve(covered_active_parts.size() + covered_outdated_parts.size());
                std::move(covered_active_parts.begin(), covered_active_parts.end(), std::back_inserter(covered_parts));
                std::move(covered_outdated_parts.begin(), covered_outdated_parts.end(), std::back_inserter(covered_parts));
                MergeTreeTransaction::addNewPartAndRemoveCovered(data.shared_from_this(), part, covered_parts, txn);
            }
        MergeTreeData::WriteAheadLogPtr wal;