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
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.nullValue;
public class EsqlActionIT extends AbstractEsqlIntegTestCase {
    long epoch = System.currentTimeMillis();
    @Before
    public void setupIndex() {
        createAndPopulateIndex("test");
    }
    public void testProjectConstant() {
        try (EsqlQueryResponse results = run("from test | eval x = 1 | keep x")) {
            assertThat(results.columns(), equalTo(List.of(new ColumnInfo("x", "integer"))));
            assertThat(getValuesList(results).size(), equalTo(40));
            assertThat(getValuesList(results).get(0).get(0), equalTo(1));
        }
    }
    public void testStatsOverConstant() {
        try (EsqlQueryResponse results = run("from test | eval x = 1 | stats x = count(x)")) {
            assertThat(results.columns(), equalTo(List.of(new ColumnInfo("x", "long"))));
            assertThat(getValuesList(results).size(), equalTo(1));
            assertThat(getValuesList(results).get(0).get(0), equalTo(40L));
        }
    }
    public void testRow() {
        long value = randomLongBetween(0, Long.MAX_VALUE);
        try (EsqlQueryResponse response = run("row " + value)) {