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(1, getValuesList(results).size());
            assertEquals("count(*)", results.columns().get(0).name());
            assertEquals("long", results.columns().get(0).type());
            assertEquals("data", results.columns().get(1).name());
            assertEquals("long", results.columns().get(1).type());
            var values = getValuesList(results).get(0);
            assertEquals(2, values.size());
            assertEquals(20, (long) values.get(0));
            assertEquals(2L, (long) values.get(1));
        }
    }
    public void testFromStatsEvalWithPragma() {
        assumeTrue("pragmas only enabled on snapshot builds", Build.current().isSnapshot());
        try (EsqlQueryResponse results = run("from test | stats avg_count = avg(count) | eval x = avg_count + 7")) {
            logger.info(results);
            assertEquals(1, getValuesList(results).size());
            assertEquals(2, getValuesList(results).get(0).size());
            assertEquals(50, (double) getValuesList(results).get(0).get(results.columns().indexOf(new ColumnInfo("x", "double"))), 1d);
            assertEquals(
                43,
                (double) getValuesList(results).get(0).get(results.columns().indexOf(new ColumnInfo("avg_count", "double"))),
                1d
            );
        }
    }
    public void testWhere() {
        try (EsqlQueryResponse results = run("from test | where count > 40")) {
            logger.info(results);
            assertEquals(30, getValuesList(results).size());
            var countIndex = results.columns().indexOf(new ColumnInfo("count", "long"));