### 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/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java
private final String toSql;
        private final String toNative;
        IndexType(String sql, String toNative) {
            this.toSql = sql;
            this.toNative = toNative;
        }
        public String toSql() {
            return toSql;
        }
        public String toNative() {
            return toNative;
        }
    }
    public record IndexInfo(String cluster, String name, IndexType type) {
        @Override
        public String toString() {
            return buildRemoteIndexName(cluster, name);
        }
    }
    public static final String SQL_TABLE = "TABLE";
    public static final String SQL_VIEW = "VIEW";
    private static final IndicesOptions INDICES_ONLY_OPTIONS = new IndicesOptions(
        EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE, Option.IGNORE_ALIASES, Option.IGNORE_THROTTLED),
        EnumSet.of(WildcardStates.OPEN)
    );
    private static final IndicesOptions FROZEN_INDICES_OPTIONS = new IndicesOptions(
        EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE, Option.IGNORE_ALIASES),
        EnumSet.of(WildcardStates.OPEN)
    );
    public static final IndicesOptions FIELD_CAPS_INDICES_OPTIONS = new IndicesOptions(