### Description

For certain mappings the following query:
```
POST _query?error_trace
{
  “query”: “”"
  from * [metadata _index] | limit 10000
  “”"
}
```

triggers a CCE:
```
{ "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)",
        "stack_trace": """org.elasticsearch.ElasticsearchException$1: class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)

Caused by: java.lang.ClassCastException: class org.elasticsearch.xpack.ql.type.UnsupportedEsField cannot be cast to class 
org.elasticsearch.xpack.ql.type.InvalidMappedField (org.elasticsearch.xpack.ql.type.UnsupportedEsField and org.elasticsearch.xpack.ql.type.InvalidMappedField are in unnamed module of loader java.net.FactoryURLClassLoader @6eb5b9e7)
	at org.elasticsearch.xpack.ql.index.IndexResolver.buildIndices(IndexResolver.java:771)
	at org.elasticsearch.xpack.ql.index.IndexResolver.mergedMappings(IndexResolver.java:466)
	at org.elasticsearch.xpack.ql.index.IndexResolver.lambda$resolveAsMergedMapping$8(IndexResolver.java:381)
	at org.elasticsearch.server@8.11.0/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:236)
	... 21 more
```
x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolverTests.java
assertEqualsMaps(oneMapping, indices.get(0).mapping());
        assertEquals(Set.of("a"), indices.get(0).concreteIndices());
        assertEqualsMaps(sameMapping, indices.get(1).mapping());
        assertEquals(Set.of("b"), indices.get(1).concreteIndices());
    }
    public void testSeparateIncompatibleTypes() throws Exception {
        Map<String, EsField> basicMapping = loadMapping("mapping-basic.json", true);
        Map<String, EsField> incompatible = loadMapping("mapping-basic-incompatible.json");
        assertNotEquals(basicMapping, incompatible);
        List<EsIndex> indices = separate(new EsIndex("basic", basicMapping), new EsIndex("incompatible", incompatible));
        assertEquals(2, indices.size());
        assertEqualsMaps(basicMapping, indices.get(0).mapping());
        assertEquals(Set.of("basic"), indices.get(0).concreteIndices());
        assertEqualsMaps(incompatible, indices.get(1).mapping());
        assertEquals(Set.of("incompatible"), indices.get(1).concreteIndices());
    }
    
    public void testMultipleCompatibleIndicesWithDifferentFields() {
        int indicesCount = randomIntBetween(2, 15);
        EsIndex[] expectedIndices = new EsIndex[indicesCount];
        
        for (int i = 0; i < indicesCount; i++) {
            Map<String, EsField> mapping = Maps.newMapWithExpectedSize(1);
            String fieldName = "field" + (i + 1);
            mapping.put(fieldName, new KeywordEsField(fieldName));
            expectedIndices[i] = new EsIndex("index" + (i + 1), mapping);
        }
        Arrays.sort(expectedIndices, Comparator.comparing(EsIndex::name));
        List<EsIndex> actualIndices = separate(expectedIndices);
        actualIndices.sort(Comparator.comparing(EsIndex::name));