### 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
Map<String, EsField> dottedMapping = loadMapping("mapping-dotted-field.json", true);
        IndexResolution resolution = merge(new EsIndex("a", dottedMapping));
        assertTrue(resolution.isValid());
        assertEqualsMaps(dottedMapping, resolution.get().mapping());
        assertEquals(Set.of("a"), resolution.get().concreteIndices());
    }
    public void testMultiLevelNestedMappings() throws Exception {
        Map<String, EsField> nestedMapping = loadMapping("mapping-nested.json", true);
        IndexResolution resolution = merge(new EsIndex("a", nestedMapping));
        assertTrue(resolution.isValid());
        assertEqualsMaps(nestedMapping, resolution.get().mapping());
    }
    public void testMetaFieldsAreIgnored() throws Exception {
        Map<String, Map<String, FieldCapabilities>> fieldCaps = new HashMap<>();
        addFieldCaps(fieldCaps, "_version", "_version", true, false, false);
        addFieldCaps(fieldCaps, "_not_meta_field", "integer", false, true, true);
        addFieldCaps(fieldCaps, "_size", "integer", true, true, true);
        addFieldCaps(fieldCaps, "_doc_count", "long", true, false, false);
        addFieldCaps(fieldCaps, "text", "keyword", true, true);
        String wildcard = "*";
        IndexResolution resolution = mergedMappings(wildcard, new String[] { "index" }, fieldCaps);
        assertTrue(resolution.isValid());
        EsIndex esIndex = resolution.get();
        assertEquals(wildcard, esIndex.name());
        assertNull(esIndex.mapping().get("_version"));
        assertNull(esIndex.mapping().get("_size"));
        assertNull(esIndex.mapping().get("_doc_count"));
        assertEquals(INTEGER, esIndex.mapping().get("_not_meta_field").getDataType());
        assertEquals(KEYWORD, esIndex.mapping().get("text").getDataType());
        assertEquals(Set.of("index"), resolution.get().concreteIndices());