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
indexRequests.add(
                client().prepareIndex().setIndex(indexName).setId(Integer.toString(i)).setSource(Map.of("val", d.val, "tag", d.tag))
            );
        }
        indexRandom(true, randomBoolean(), indexRequests);
        int limit = randomIntBetween(1, 10);
        String command = "from test_extract_fields | sort val | limit " + limit;
        try (EsqlQueryResponse results = run(command)) {
            logger.info(results);
            
            assertThat(results.columns().size(), equalTo(2));
            assertThat(getValuesList(results), hasSize(Math.min(limit, numDocs)));
            assertThat(results.columns().get(1).name(), equalTo("val"));
            assertThat(results.columns().get(0).name(), equalTo("tag"));
            List<Doc> actualDocs = new ArrayList<>();
            for (int i = 0; i < getValuesList(results).size(); i++) {
                List<Object> values = getValuesList(results).get(i);
                actualDocs.add(new Doc((Long) values.get(1), (String) values.get(0)));
            }
            assertThat(actualDocs, equalTo(allDocs.stream().limit(limit).toList()));
        }
    }
    public void testEvalWithNullAndAvg() {
        try (EsqlQueryResponse results = run("from test | eval nullsum = count_d + null | stats avg(nullsum)")) {
            logger.info(results);
            assertEquals(1, results.columns().size());
            assertEquals(1, getValuesList(results).size());
            assertEquals("avg(nullsum)", results.columns().get(0).name());
            assertEquals("double", results.columns().get(0).type());
            assertEquals(1, getValuesList(results).get(0).size());