pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.39k stars 5.85k forks source link

Wrong schema of `ExchangeSender` when expand operator is enabled #56367

Open gengliqi opened 2 months ago

gengliqi commented 2 months ago

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)

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

gengliqi commented 2 months ago

/sig planner

gengliqi commented 2 months ago

/cc @AilinKid