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
assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("b"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(42d), List.of(44d)));
        }
    }
    public void testFromProjectStatsGroupByAlias() {
        try (EsqlQueryResponse results = run("from test | rename data as d | keep d, count | stats avg(count) by d")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("avg(count)", "d"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double", "long"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L)));
        }
    }
    public void testFromProjectStatsAggregateAlias() {
        try (EsqlQueryResponse results = run("from test | rename count as c | keep c, data | stats avg(c) by data")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("avg(c)", "data"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("double", "long"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(42d, 1L), List.of(44d, 2L)));
        }
    }
    public void testFromEvalStats() {
        try (EsqlQueryResponse results = run("from test | eval ratio = data_d / count_d | stats avg(ratio)")) {
            logger.info(results);
            assertEquals(1, results.columns().size());
            assertEquals(1, getValuesList(results).size());
            assertEquals("avg(ratio)", results.columns().get(0).name());
            assertEquals("double", results.columns().get(0).type());
            assertEquals(1, getValuesList(results).get(0).size());
            assertEquals(0.034d, (double) getValuesList(results).get(0).get(0), 0.001d);