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
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */
package org.elasticsearch.xpack.esql.stats;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.PointValues;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.index.mapper.ConstantFieldType;
import org.elasticsearch.index.mapper.DocCountFieldMapper.DocCountFieldType;
import org.elasticsearch.index.mapper.IdFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.NumberFieldMapper.NumberFieldType;
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
import org.elasticsearch.xpack.ql.type.DataType;
import java.io.IOException;
import java.util.LinkedHashMap;