The ES|QL `COUNT_DISTINCT` function fails with an `illegal agg type: text` error when it's run on a `text` field. It's fine with `keyword` fields. Compare to for example `COUNT`, which runs fine on text fields:

```
PUT test/_doc/1
{
  "foo": "bar"
}

# This fails with illegal agg type: text:
POST /_query
{
  "query": """
    FROM test
    | STATS count = COUNT_DISTINCT(foo)
  """
}

# This works:
POST /_query
{
  "query": """
    FROM test
    | STATS count = COUNT_DISTINCT(foo.keyword)
  """
}

# COUNT is fine with text fields:
POST /_query
{
  "query": """
    FROM test
    | STATS count = COUNT(foo)
  """
}
```

Full error message:

```
{
  "error": {
    "root_cause": [
      {
        "type": "esql_illegal_argument_exception",
        "reason": "illegal agg type: text"
      }
    ],
    "type": "esql_illegal_argument_exception",
    "reason": "illegal agg type: text"
  },
  "status": 500
}
```
x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlActionIT.java
Iterator<Iterator<Object>> values = resp.values();
                Map<String, Long> actual = new HashMap<>();
                while (values.hasNext()) {
                    Iterator<Object> row = values.next();
                    Long v = (Long) row.next();
                    String k = (String) row.next();
                    actual.put(k, v);
                }
                assertThat(actual, equalTo(groups));
            }
        }
    }
    public void testFilterNestedFields() {
        assertAcked(client().admin().indices().prepareCreate("index-1").setMapping("file.name", "type=keyword"));
        assertAcked(client().admin().indices().prepareCreate("index-2").setMapping("file", "type=keyword"));
        try (var resp = run("from index-1,index-2 | where file.name is not null")) {
            var valuesList = getValuesList(resp);
            assertEquals(2, resp.columns().size());
            assertEquals(0, valuesList.size());
        }
    }
    public void testStatsNestFields() {
        String node1 = internalCluster().startDataOnlyNode();
        String node2 = internalCluster().startDataOnlyNode();
        assertAcked(
            client().admin()
                .indices()
                .prepareCreate("index-1")
                .setSettings(Settings.builder().put("index.routing.allocation.require._name", node1))
                .setMapping("field_1", "type=integer")