Query:
```sql
SELECT round(avg(log(2) * number), 6) AS k FROM numbers(10000000)
GROUP BY (number % 2) * (number % 3), number % 3, number % 2
HAVING avg(log(2) * number) > 3465735.3 ORDER BY k
SETTINGS allow_experimental_analyzer=1, optimize_group_by_function_keys=0;
```
Output:
```
Ok.

0 rows in set. Elapsed: 0.079 sec. Processed 10.01 million rows, 80.06 MB (127.02 million rows/s., 1.02 GB/s.)
```

Query:
```sql
SELECT round(avg(log(2) * number), 6) AS k FROM numbers(10000000)
GROUP BY (number % 2) * (number % 3), number % 3, number % 2
HAVING avg(log(2) * number) > 3465735.3 ORDER BY k
SETTINGS allow_experimental_analyzer=0, optimize_group_by_function_keys=0;
```

Output:
```
┌──────────────k─┐
│   3465735.9028 │
│   3465735.9028 │
│ 3465736.595947 │
└────────────────┘

3 rows in set. Elapsed: 0.085 sec. Processed 10.01 million rows, 80.06 MB (117.56 million rows/s., 940.52 MB/s.)
```

cc @kitaisreal 
#include <Analyzer/Passes/AggregateFunctionsArithmericOperationsPass.h>
#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <AggregateFunctions/IAggregateFunction.h>
#include <Functions/IFunction.h>
#include <Analyzer/InDepthQueryTreeVisitor.h>
#include <Analyzer/ConstantNode.h>
#include <Analyzer/FunctionNode.h>
namespace DB
{
namespace ErrorCodes
{
    extern const int BAD_TYPE_OF_FIELD;
}
namespace
{
Field zeroField(const Field & value)