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
public void testRowStatsProjectGroupByInt() {
        try (EsqlQueryResponse results = run("row a = 1, b = 2 | stats count(b) by a | keep a")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("integer"));
            assertThat(getValuesList(results), contains(List.of(1)));
        }
    }
    public void testRowStatsProjectGroupByLong() {
        try (EsqlQueryResponse results = run("row a = 1000000000000, b = 2 | stats count(b) by a | keep a")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long"));
            assertThat(getValuesList(results), contains(List.of(1000000000000L)));
        }
    }
    public void testRowStatsProjectGroupByDouble() {
        try (EsqlQueryResponse results = run("row a = 1.0, b = 2 | stats count(b) by a | keep a")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double"));
            assertThat(getValuesList(results), contains(List.of(1.0)));
        }
    }
    public void testRowStatsProjectGroupByKeyword() {
        try (EsqlQueryResponse results = run("row a = \"hello\", b = 2 | stats count(b) by a | keep a")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("a"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("keyword"));
            assertThat(getValuesList(results), contains(List.of("hello")));