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
}
        client().admin().indices().prepareRefresh("test").get();
        for (String field : List.of("count", "count_d")) {
            try (EsqlQueryResponse results = run("from test | stats avg = avg(" + field + ") by color")) {
                logger.info(results);
                assertEquals(2, results.columns().size());
                assertEquals(5, getValuesList(results).size());
                
                assertEquals("avg", results.columns().get(0).name());
                assertEquals("double", results.columns().get(0).type());
                assertEquals("color", results.columns().get(1).name());
                assertEquals("keyword", results.columns().get(1).type());
                record Group(String color, Double avg) {
                }
                List<Group> expectedGroups = List.of(
                    new Group(null, 120.0),
                    new Group("blue", 42.0),
                    new Group("green", 44.0),
                    new Group("red", 43.0),
                    new Group("yellow", null)
                );
                List<Group> actualGroups = getValuesList(results).stream()
                    .map(l -> new Group((String) l.get(1), (Double) l.get(0)))
                    .sorted(Comparator.comparing(c -> c.color, Comparator.nullsFirst(String::compareTo)))
                    .toList();
                assertThat(actualGroups, equalTo(expectedGroups));
            }
        }
    }
    public void testFromStatsMultipleAggs() {