```
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;
```
{
    part->is_temp = false;
    part->setState(DataPartState::PreActive);
    assert([&]()
           {
               String dir_name = fs::path(part->getDataPartStorage().getRelativePath()).filename();
               bool may_be_cleaned_up = dir_name.starts_with("tmp_") || dir_name.starts_with("tmp-fetch_");
               return !may_be_cleaned_up || temporary_parts.contains(dir_name);
           }());
    if (need_rename)
        part->renameTo(part->name, true);
    data_parts_indexes.insert(part);
    out_transaction.addPart(part);
}
bool MergeTreeData::addTempPart(
    MutableDataPartPtr & part,
    Transaction & out_transaction,
    DataPartsLock & lock,
    DataPartsVector * out_covered_parts)
{
    LOG_TRACE(log, "Adding temporary part from directory {} with name {}.", part->getDataPartStorage().getPartDirectory(), part->name);
    if (&out_transaction.data != this)
        throw Exception("MergeTreeData::Transaction for one table cannot be used with another. It is a bug.",
            ErrorCodes::LOGICAL_ERROR);
    if (part->hasLightweightDelete())
        has_lightweight_delete_parts.store(true);
    checkPartPartition(part, lock);