```sql
SELECT toStartOfHour(time) AS timex, id, count()
FROM
(
    SELECT
        concat('id', toString(number % 3)) AS id,
        toDateTime('2020-01-01') + (number * 60) AS time
    FROM numbers(100)
)
GROUP BY
    GROUPING SETS ( (timex, id), (timex))
ORDER BY timex ASC;

Received exception from server (version 22.5.1):
Code: 215. DB::Exception: Received from localhost:9000. 
DB::Exception: Column `time` is not under aggregate function and not in GROUP BY: 
While processing time ASC. (NOT_AN_AGGREGATE)
```
{
    RewriteFunctionToSubcolumnVisitor::Data data{metadata_snapshot};
    RewriteFunctionToSubcolumnVisitor(data).visit(query);
}
std::shared_ptr<ASTFunction> getQuantileFuseCandidate(const String & func_name, std::vector<ASTPtr *> & functions)
{
    if (functions.size() < 2)
        return nullptr;
    const auto & common_arguments = (*functions[0])->as<ASTFunction>()->arguments->children;
    auto func_base = makeASTFunction(GatherFunctionQuantileData::getFusedName(func_name));
    func_base->arguments->children = common_arguments;
    func_base->parameters = std::make_shared<ASTExpressionList>();
    for (const auto * ast : functions)
    {
        assert(ast && *ast);
        const auto * func = (*ast)->as<ASTFunction>();
        assert(func && func->parameters->as<ASTExpressionList>());
        const ASTs & parameters = func->parameters->as<ASTExpressionList &>().children;
        if (parameters.size() != 1)
            return nullptr; 
        func_base->parameters->children.push_back(parameters[0]);
    }
    return func_base;
}
void optimizeFuseQuantileFunctions(ASTPtr & query)