```
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;
```
const DataPartPtr & part,
    DataPartsLock & data_parts_lock) const
{
    part->assertState({DataPartState::Active, DataPartState::PreActive});
    PartHierarchy hierarchy = getPartHierarchy(part->info, DataPartState::Outdated, data_parts_lock);
    if (hierarchy.duplicate_part)
        throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected duplicate part {}. It is a bug.", hierarchy.duplicate_part->getNameWithState());
    return hierarchy.covered_parts;
}
MergeTreeData::DataPartsVector MergeTreeData::getActivePartsToReplace(
    const MergeTreePartInfo & new_part_info,
    const String & new_part_name,
    DataPartPtr & out_covering_part,
    DataPartsLock & data_parts_lock) const
{
    PartHierarchy hierarchy = getPartHierarchy(new_part_info, DataPartState::Active, data_parts_lock);
    if (!hierarchy.intersected_parts.empty())
        throw Exception(ErrorCodes::LOGICAL_ERROR, "Part {} intersects part {}. It is a bug.",
                        new_part_name, hierarchy.intersected_parts.back()->getNameWithState());
    if (hierarchy.duplicate_part)
        throw Exception(ErrorCodes::LOGICAL_ERROR, "Unexpected duplicate part {}. It is a bug.", hierarchy.duplicate_part->getNameWithState());
    if (!hierarchy.covering_parts.empty())
        out_covering_part = std::move(hierarchy.covering_parts.back());
    return std::move(hierarchy.covered_parts);
}
void MergeTreeData::checkPartPartition(MutableDataPartPtr & part, DataPartsLock & lock) const