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
);
        assertAcked(
            client().admin()
                .indices()
                .prepareCreate("bar-index")
                .setSettings(Settings.builder().put("index.routing.allocation.require._name", node2))
                .setMapping("bar_int", "type=integer", "bar_long", "type=long", "bar_float", "type=float", "bar_double", "type=double")
        );
        var fields = List.of("foo_int", "foo_long", "foo_float", "foo_double");
        var functions = List.of("sum", "count", "avg", "count_distinct");
        for (String field : fields) {
            for (String function : functions) {
                String stat = String.format(Locale.ROOT, "stats s = %s(%s)", function, field);
                String command = String.format(Locale.ROOT, "from foo-index,bar-index | where %s is not null | %s", field, stat);
                try (var resp = run(command)) {
                    var valuesList = getValuesList(resp);
                    assertEquals(1, resp.columns().size());
                    assertEquals(1, valuesList.size());
                }
            }
        }
    }
    private void createNestedMappingIndex(String indexName) throws IOException {
        XContentBuilder builder = JsonXContent.contentBuilder();
        builder.startObject();
        {
            builder.startObject("properties");
            {
                builder.startObject("nested");
                {