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/main/java/org/elasticsearch/xpack/esql/planner/AggregateMapper.java
case LONG -> DataTypes.LONG;
            case DOUBLE -> DataTypes.DOUBLE;
            default -> throw new EsqlIllegalArgumentException("unsupported agg type: " + elementType);
        };
    }
    
    static String dataTypeToString(DataType type, Class<?> aggClass) {
        if (aggClass == Count.class) {
            return "";  
        }
        if (type.equals(DataTypes.BOOLEAN)) {
            return "Boolean";
        } else if (type.equals(DataTypes.INTEGER)) {
            return "Int";
        } else if (type.equals(DataTypes.LONG) || type.equals(DataTypes.DATETIME)) {
            return "Long";
        } else if (type.equals(DataTypes.DOUBLE)) {
            return "Double";
        } else if (type.equals(DataTypes.KEYWORD) || type.equals(DataTypes.IP)) {
            return "BytesRef";
        } else {
            throw new EsqlIllegalArgumentException("illegal agg type: " + type.typeName());
        }
    }
    static Expression unwrapAlias(Expression expression) {
        if (expression instanceof Alias alias) return alias.child();
        return expression;
    }
}