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
assertEquals(List.of(List.of(value)), getValuesList(response));
        }
    }
    public void testFromStatsGroupingAvgWithSort() {
        testFromStatsGroupingAvgImpl("from test | stats avg(count) by data | sort data | limit 2", "data", "avg(count)");
    }
    public void testFromStatsGroupingAvg() {
        testFromStatsGroupingAvgImpl("from test | stats avg(count) by data", "data", "avg(count)");
    }
    public void testFromStatsGroupingAvgWithAliases() {
        testFromStatsGroupingAvgImpl("from test | eval g = data | stats f = avg(count) by g", "g", "f");
    }
    private void testFromStatsGroupingAvgImpl(String command, String expectedGroupName, String expectedFieldName) {
        try (EsqlQueryResponse results = run(command)) {
            logger.info(results);
            assertEquals(2, results.columns().size());
            
            ColumnInfo valuesColumn = results.columns().get(0);
            assertEquals(expectedFieldName, valuesColumn.name());
            assertEquals("double", valuesColumn.type());
            ColumnInfo groupColumn = results.columns().get(1);
            assertEquals(expectedGroupName, groupColumn.name());
            assertEquals("long", groupColumn.type());
            
            List<List<Object>> valueValues = getValuesList(results);
            assertEquals(2, valueValues.size());
            
            if ((long) valueValues.get(0).get(1) == 1L) {
                assertEquals(42.0, (double) valueValues.get(0).get(0), 0.0);
                assertEquals(2L, (long) valueValues.get(1).get(1));