```
row x = 1, y = 2, z = 3 | stats  a = count(*), b = count(*) | stats  c = count(*)
```

The logical optimizer does not seem to be able to handle this query:

```
{
    "error": {
        "root_cause": [
            {
                "type": "rule_execution_exception",
                "reason": "Rule execution limit [100] reached"
            }
        ],
        "type": "rule_execution_exception",
        "reason": "Rule execution limit [100] reached"
    },
    "status": 500
}
```

The problem seems to be limited to this corner case scenario where you have two aggs with the same expression in one STATS and another STATS after that.

The problem is not limited to `count(*)`, also the following fails with the same error

```
row x = 1, y = 2, z = 3 | stats  a = max(x), b = max(x) | stats  c = max(a)
```

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizer.java
@Override
        public LogicalPlan apply(LogicalPlan logicalPlan) {
            Holder<Boolean> enabled = new Holder<>(false);
            return logicalPlan.transformDown(p -> {
                
                if (p instanceof Aggregate || p instanceof Project) {
                    enabled.set(true);
                } else if (enabled.get() && p instanceof Eval eval) {
                    p = rule(eval);
                }
                return p;
            });
        }
        private LogicalPlan rule(Eval eval) {
            LogicalPlan plan = eval;
            
            AttributeMap<Expression> basicAliases = new AttributeMap<>();
            
            AttributeMap<NamedExpression> basicAliasSources = new AttributeMap<>();
            List<Alias> keptFields = new ArrayList<>();
            var fields = eval.fields();
            for (int i = 0, size = fields.size(); i < size; i++) {
                Alias field = fields.get(i);
                Expression child = field.child();
                var attribute = field.toAttribute();
                
                if (child instanceof Attribute) {
                    basicAliases.put(attribute, child);
                    basicAliasSources.put(attribute, field);