Similar to the bug reported in https://github.com/elastic/elasticsearch/issues/100186, it seems that stats over multiple indices where some might be missing the column generate errors:

    FROM logs-* | STATS count=count(*) BY agent.version

Results in:

    ValuesSources are mismatched

This happens in benchmarking tests where very little data is generated. The full benchmarks have all data generated, and the error does not occur, so we presume the issue might be either:

* A mismatch between documents created and index mappings
* Or missing data in indexes that do have this field mapped

The error trace is:

```
java.lang.IllegalStateException: ValuesSources are mismatched
	at org.elasticsearch.compute.operator.OrdinalsGroupingOperator.<init>(OrdinalsGroupingOperator.java:102)
	at org.elasticsearch.compute.operator.OrdinalsGroupingOperator.get(OrdinalsGroupingOperator.java:64)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.lambda-zsh(LocalExecutionPlanner.java:646)
	at java.base/java.util.stream.ReferencePipeline.accept(ReferencePipeline.java:197)
	at java.base/java.util.ArrayList.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.operators(LocalExecutionPlanner.java:646)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.apply(LocalExecutionPlanner.java:730)
	at org.elasticsearch.xpack.esql.planner.LocalExecutionPlanner.createDrivers(LocalExecutionPlanner.java:773)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.runCompute(ComputeService.java:265)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda(ComputeService.java:432)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener.onResponse(ActionListener.java:177)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.action.ActionListener.completeWith(ActionListener.java:305)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.lambda(ComputeService.java:301)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.index.shard.IndexShard.ensureShardSearchActive(IndexShard.java:3932)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.acquireSearchContexts(ComputeService.java:299)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.messageReceived(ComputeService.java:430)
	at org.elasticsearch.xpack.esql.plugin.ComputeService.messageReceived(ComputeService.java:422)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.transport.TransportService.doRun(TransportService.java:1020)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext.doRun(ThreadContext.java:983)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.ThreadContext.doRun(ThreadContext.java:983)
	at org.elasticsearch.server@8.12.0-SNAPSHOT/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1623)
```

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java
record Group(Long data, Long count, String color) {
                Group(Long data, Long count) {
                    this(data, count, "yellow");
                }
            }
            List<Group> expectedGroups = List.of(
                
                new Group(null, 50L),
                new Group(null, 60L),
                new Group(null, 70L),
                new Group(null, 80L),
                new Group(null, 90L),
                new Group(null, 100L),
                new Group(10L, null),
                new Group(10L, 100L),
                new Group(9L, null),
                new Group(9L, 90L)
            );
            List<Group> actualGroups = getValuesList(results).stream()
                .map(l -> new Group((Long) l.get(0), (Long) l.get(1), (String) l.get(2)))
                .toList();
            assertThat(actualGroups, equalTo(expectedGroups));
        }
    }
    /**
     * This test covers the scenarios where Lucene is throwing a {@link org.apache.lucene.search.CollectionTerminatedException} when
     * it's signaling that it could stop collecting hits early. For example, in the case the index is sorted in the same order as the query.
     * The {@link org.elasticsearch.compute.lucene.LuceneTopNSourceOperator#getOutput()} is handling this exception by
     * ignoring it (which is the right thing to do) and sort of cleaning up and moving to the next docs collection.
     */