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
l -> new Group((Double) l.get(0), (Long) l.get(1), (Long) l.get(2), (Long) l.get(3), (Long) l.get(4), (String) l.get(5))
                )
                .sorted(comparing(c -> c.color))
                .toList();
            assertThat(actualGroups, equalTo(expectedGroups));
        }
    }
    public void testFromSortWithTieBreakerLimit() {
        try (EsqlQueryResponse results = run("from test | sort data, count desc, time | limit 5 | keep data, count, time")) {
            logger.info(results);
            assertThat(
                getValuesList(results),
                contains(
                    List.of(1L, 44L, epoch + 2),
                    List.of(1L, 44L, epoch + 6),
                    List.of(1L, 44L, epoch + 10),
                    List.of(1L, 44L, epoch + 14),
                    List.of(1L, 44L, epoch + 18)
                )
            );
        }
    }
    public void testFromStatsProjectGroup() {
        try (EsqlQueryResponse results = run("from test | stats avg_count = avg(count) by data | keep data")) {
            logger.info(results);
            assertThat(results.columns().stream().map(ColumnInfo::name).toList(), contains("data"));
            assertThat(results.columns().stream().map(ColumnInfo::type).toList(), contains("long"));
            assertThat(getValuesList(results), containsInAnyOrder(List.of(1L), List.of(2L)));
        }
    }