-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Describe the bug
The null result of union stmt is incorrect when the child of union stmt is a outer join with the null-supplying column.
To Reproduce
mysql> CREATE TABLE empty (
-> k1 tinyint(4) NOT NULL COMMENT "",
-> k2 tinyint(4) NOT NULL COMMENT ""
-> ) ENGINE=OLAP
-> AGGREGATE KEY(k1, k2)
-> DISTRIBUTED BY HASH(k1) BUCKETS 5
-> PROPERTIES (
-> "storage_type" = "COLUMN", "replication_num" = "1"
-> );
Query OK, 0 rows affected (0.19 sec)
mysql> CREATE TABLE left_table (
-> k1 tinyint(4) NOT NULL COMMENT "",
-> k2 tinyint(4) NOT NULL COMMENT ""
-> ) ENGINE=OLAP
-> AGGREGATE KEY(k1, k2)
-> DISTRIBUTED BY HASH(k1) BUCKETS 5
-> PROPERTIES (
-> "storage_type" = "COLUMN", "replication_num" = "1"
-> );
Query OK, 0 rows affected (0.07 sec)
mysql> insert into left_table values (1,1);
Query OK, 1 row affected (0.29 sec)
mysql> (select k2 from empty) union (select b.k2 k2 from left_table a left join empty b on a.k1=b.k1);
+------+
| k2 |
+------+
| 0 |
+------+
1 row in set (0.09 sec)
mysql> select b.k2 k2 from left_table a left join empty b on a.k1=b.k1;
+------+
| k2 |
+------+
| NULL |
+------+
1 row in set (0.07 sec)
Expected behavior
+------+
| k2 |
+------+
| NULL |
+------+
Additional context
The NULL column must be produced by a outer join.