Reproduces more or less deterministically on https://demo.elastic.co

```
POST _query
{
  "query":"from metrics-* | stats avg(event.duration) | limit 10"
}
```

```
Caused by: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.index.mapper.MappedFieldType.typeName()" because "fieldType" is null
	at org.elasticsearch.xpack.esql.stats.SearchStats.detectSingleValue(SearchStats.java:185)
	at org.elasticsearch.xpack.esql.stats.SearchStats.lambda$isSingleValue$10(SearchStats.java:168)
	at org.elasticsearch.xpack.esql.stats.SearchStats.doWithContexts(SearchStats.java:283)
	at org.elasticsearch.xpack.esql.stats.SearchStats.isSingleValue(SearchStats.java:167)
	at org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizer$PushStatsToSource.lambda$pushableStats$0(LocalPhysicalPlanOptimizer.java:379)
	at java.util.Map.computeIfAbsent(Map.java:1066)
	at org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizer$PushStatsToSource.pushableStats(LocalPhysicalPlanOptimizer.java:364)
	at org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizer$PushStatsToSource.rule(LocalPhysicalPlanOptimizer.java:331)
	at org.elasticsearch.xpack.esql.optimizer.LocalPhysicalPlanOptimizer$PushStatsToSource.rule(LocalPhysicalPlanOptimizer.java:323)
	at org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules$ParameterizedOptimizerRule.lambda$apply$0(PhysicalOptimizerRules.java:37)

```


x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/stats/SearchStats.java
for (LeafReaderContext context : indexReader.leaves()) {
                LeafReader reader = context.reader();
                FieldInfos fieldInfos = reader.getFieldInfos();
                FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
                if (fieldInfo != null) {
                    if (fieldInfo.getDocValuesType() == DocValuesType.NONE) {
                        
                        return -1;
                    }
                    if (fieldInfo.getPointIndexDimensionCount() > 0) {
                        PointValues points = reader.getPointValues(field);
                        if (points != null) {
                            count += points.getDocCount();
                        }
                    } else if (fieldInfo.getIndexOptions() != IndexOptions.NONE) {
                        Terms terms = reader.terms(field);
                        if (terms != null) {
                            count += terms.getDocCount();
                        }
                    } else {
                        return -1; 
                    }
                }
            }
        } catch (IOException ex) {
            throw new EsqlIllegalArgumentException("Cannot access data storage", ex);
        }
        return count;
    }
    private interface IndexReaderConsumer {