```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)
```
"dictGetFloat64",
        "dictGetDate",
        "dictGetDateTime"
};
/** You can not completely remove GROUP BY. Because if there were no aggregate functions, then it turns out that there will be no aggregation.
  * Instead, leave `GROUP BY const`.
  * Next, see deleting the constants in the analyzeAggregation method.
  */
void appendUnusedGroupByColumn(ASTSelectQuery * select_query)
{
    
    
    
    select_query->setExpression(ASTSelectQuery::Expression::GROUP_BY, std::make_shared<ASTExpressionList>());
    select_query->groupBy()->children.emplace_back(std::make_shared<ASTLiteral>(static_cast<Int64>(-1)));
}
void optimizeGroupBy(ASTSelectQuery * select_query, ContextPtr context)
{
    const FunctionFactory & function_factory = FunctionFactory::instance();
    if (!select_query->groupBy())
        return;
    const auto is_literal = [] (const ASTPtr & ast) -> bool
    {
        return ast->as<ASTLiteral>();
    };
    auto & group_exprs = select_query->groupBy()->children;
    
    const auto remove_expr_at_index = [&group_exprs] (const size_t idx)
    {
        if (idx < group_exprs.size() - 1)