# [Know Issue]关于 TiDB v4 TiDB count Null 行为与 MySQL 不一致

## Key Words

聚合统计,Unsupported type: Null,count Null

## Description

执行以下 SQL 报错 Unsupported type: Null

```sql
SELECT 
    org_identifier , 
    COUNT( IF(`type` = 'DB' , dis_identifier , NULL) ) AS db_cnt
FROM `vw_distribution_sub_new` 
    GROUP BY `org_identifier`;

other error: [components/tidb_query/src/batch/runner.rs:96]: BatchSlowHashAggregationExecutor: Evaluate error: [components/tidb_query/src/aggr_fn/parser.rs:72]: Aggregation function meet blacklist expr type Count: Evaluate error: [components/tidb_query/src/rpn_expr/types/expr_builder.rs:26]: Unsupported type: Null
```

## Root Cause

1. 虽然 COUNT(NULL) 似乎没有任何意义，但在 MySQL 8.0 和 Postgres 13 中返回数字是 0 而不是 error， 所以 v4 及之前版本 TiDB 不支持 count Null 。
2. TiKV 在 v5.0.0 开始支持使用 EvalType::Bytes 转换 Null type 并在 TiDB 层面兼容 MySQL 8.0 行为。

## Resolution

升级至 v5.0.0 及以上版本

## Affected Versions

~ v5.0.0
