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 testIndexPatterns() throws Exception {
        String[] indexNames = { "test_index_patterns_1", "test_index_patterns_2", "test_index_patterns_3" };
        int i = 0;
        for (String indexName : indexNames) {
            assertAcked(
                client().admin()
                    .indices()
                    .prepareCreate(indexName)
                    .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 5)))
                    .setMapping("data", "type=long", "count", "type=long")
            );
            ensureYellow(indexName);
            client().prepareBulk()
                .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
                .add(new IndexRequest(indexName).id("1").source("data", ++i, "count", i * 1000))
                .add(new IndexRequest(indexName).id("2").source("data", ++i, "count", i * 1000))
                .add(new IndexRequest(indexName).id("3").source("data", ++i, "count", i * 1000))
                .add(new IndexRequest(indexName).id("4").source("data", ++i, "count", i * 1000))
                .add(new IndexRequest(indexName).id("5").source("data", ++i, "count", i * 1000))
                .get();
        }
        try (var results = run("from test_index_patterns* | stats count(data), sum(count)")) {
            assertEquals(1, getValuesList(results).size());
            assertEquals(15L, getValuesList(results).get(0).get(0));
            assertEquals(120000L, getValuesList(results).get(0).get(1));
        }
        try (var results = run("from test_index_patterns_1,test_index_patterns_2 | stats count(data), sum(count)")) {
            assertEquals(1, getValuesList(results).size());