pingcap / pingcap/tidb

Wrong schema of `ExchangeSender` when expand operator is enabled

Open
#56,367 2 comments 0 reactions 2 assignees Claimed by @AilinKid View on GitHub
affects-8.5 may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

See https://github.com/pingcap/tiflash/issues/9314.
In the case above, the schema of `ExchangeSender_40` should be `(nullable_int64, nullable_int64, int64)` but the TiDB gives `(int64, int64, int64)`, causing the error when converting a nullable type to a non-nullable type.

### 1. Minimal reproduce step (Required)
```sql
mysql> create table t(a int not null, b int not null);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t values(1,2);
Query OK, 1 row affected (0.03 sec)

mysql> alter table t set tiflash replica 1;
Query OK, 0 rows affected (0.06 sec)

mysql> set @@tidb_opt_enable_three_stage_multi_distinct_agg=on;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(distinct a), count(distinct b) from t;
ERROR 1105 (HY000): other error for mpp stream: Code: 349, e.displayText() = DB::Exception: Cannot convert NULL value to non-Nullable type, e.what() = DB::Exception,
```

### 2. What did you expect to see? (Required)
Run successfully

### 3. What did you see instead (Required)
Error

### 4. What is your TiDB version? (Required)
Master

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.