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
int randomValue = randomIntBetween(0, 100);
            countValuesGreaterThanFifty += randomValue >= 50 ? 1 : 0;
            builder.startObject();
            {
                builder.field("data", randomValue);
                builder.startArray("nested");
                {
                    for (int k = 0, max = randomIntBetween(1, 5); k < max; k++) {
                        
                        builder.startObject().field("foo", randomIntBetween(1000, 10000)).endObject();
                    }
                }
                builder.endArray();
            }
            builder.endObject();
            bulkBuilder.add(new IndexRequest(indexName).id(Integer.toString(j)).source(builder));
        }
        bulkBuilder.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
        ensureYellow(indexName);
        return countValuesGreaterThanFifty;
    }
    private void createAlias(List<String> indices, String alias) throws InterruptedException, ExecutionException {
        IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest();
        for (String indexName : indices) {
            aliasesRequest.addAliasAction(IndicesAliasesRequest.AliasActions.add().index(indexName).alias(alias));
        }
        assertAcked(admin().indices().aliases(aliasesRequest).get());
    }
    private void assertNoNestedDocuments(String query, int docsCount, long minValue, long maxValue) {
        try (EsqlQueryResponse results = run(query)) {