```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)
```
{
    GatherFunctionQuantileVisitor::Data data{};
    GatherFunctionQuantileVisitor(data).visit(query);
    for (auto & candidate : data.fuse_quantile)
    {
        String func_name = candidate.first;
        auto & args_to_functions = candidate.second;
        
        for (auto it : args_to_functions.arg_map_function)
        {
            std::vector<ASTPtr *> & functions = it.second;
            auto func_base = getQuantileFuseCandidate(func_name, functions);
            if (!func_base)
                continue;
            for (size_t i = 0; i < functions.size(); ++i)
            {
                std::shared_ptr<ASTFunction> ast_new = makeASTFunction("arrayElement", func_base, std::make_shared<ASTLiteral>(i + 1));
                if (const auto & alias = (*functions[i])->tryGetAlias(); !alias.empty())
                    ast_new->setAlias(alias);
                *functions[i] = ast_new;
            }
        }
    }
}
void optimizeOrLikeChain(ASTPtr & query)