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 testFromStatsProjectGroupByDouble() {
        try (EsqlQueryResponse results = run("from test | stats count(count) by data_d | keep data_d")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("data_d"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(1.0), List.of(2.0)));
        }
    }
    public void testFromStatsProjectGroupWithAlias() {
        String query = "from test | stats avg_count = avg(count) by data | eval d2 = data | rename data as d | keep d, d2";
        try (EsqlQueryResponse results = run(query)) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("d", "d2"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long", "long"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(1L, 1L), List.of(2L, 2L)));
        }
    }
    public void testFromStatsProjectAgg() {
        try (EsqlQueryResponse results = run("from test | stats a = avg(count) by data | 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), containsInAnyOrder(List.of(42d), List.of(44d)));
        }
    }
    public void testFromStatsProjectAggWithAlias() {
        try (EsqlQueryResponse results = run("from test | stats a = avg(count) by data | rename a as b | keep b")) {
            logger.info(results);