We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CREATE TABLE t1 ( id bigint(64) NOT NULL AUTO_INCREMENT, col1 varchar(511) DEFAULT NULL, PRIMARY KEY (id) );
t1
id
col1
INSERT INTO t1 VALUES (1,'0'),(2,'NULL'),(3,'false'),(4,NULL),(5,NULL),(6,NULL),(7,''),(8,'0000-00-00 00:00:00'),(9,' ');
CREATE TABLE t2 ( id bigint(64) NOT NULL AUTO_INCREMENT, col1 varchar(511) DEFAULT NULL, PRIMARY KEY (id) ) ;
t2
INSERT INTO t2 VALUES (1,''),(2,NULL),(3,NULL),(4,''),(5,NULL),(6,NULL),(7,NULL),(8,''),(9,'-1'),(10,'-0'),(11,'1'),(12,'1'),(13,' '),(14,'0000-00-00 00:00:00');
CREATE TABLE t3 ( id bigint(64) NOT NULL AUTO_INCREMENT, col1 varchar(511) DEFAULT NULL, PRIMARY KEY (id) );
t3
INSERT INTO t3 VALUES (15,'0000-00-00 00:00:00'),(16,NULL),(17,NULL),(18,'NULL'),(19,'-0'),(20,NULL),(21,''),(22,'-0');
Correct Merge Join when transforming hash join to merge join.
mysql> SELECT /+ merge_join(t1, t2, t3)/ t3.col1 FROM (t1 LEFT JOIN t2 ON t1.col1=t2.col1) LEFT JOIN t3 ON t2.col1=t3.col1; +------+ | col1 | +------+ | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | +------+ 11 rows in set (0.00 sec)
mysql> SELECT /+ hash_join(t1, t2, t3)/ t3.col1 FROM (t1 LEFT JOIN t2 ON t1.col1=t2..col1) LEFT JOIN t3 ON t2.col1=t3.col1; +---------------------+ | col1 | +---------------------+ | NULL | | NULL | | NULL | | NULL | | NULL | | NULL | | | | | | | | 0000-00-00 00:00:00 | | NULL | +---------------------+ 11 rows in set (0.00 sec)
mysql> SELECT tidb_version(); +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | tidb_version() | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Release Version: v5.4.0 Edition: Community Git Commit Hash: 55f3b24 Git Branch: heads/refs/tags/v5.4.0 UTC Build Time: 2022-01-25 08:39:26 GoVersion: go1.16.4 Race Enabled: false TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306 Check Table Before Drop: false | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
The text was updated successfully, but these errors were encountered:
The following sql works fine.
SELECT /*+ merge_join(t1, t2, t3)*/ t3.col1 FROM (select t2.col1 from t1 LEFT JOIN t2 ON t1.col1=t2.col1) t2 LEFT JOIN t3 ON t2.col1=t3.col1;
Duplicate with #33042
Sorry, something went wrong.
No branches or pull requests
Bug Report
1. Minimal reproduce step
CREATE TABLE
t1
(id
bigint(64) NOT NULL AUTO_INCREMENT,col1
varchar(511) DEFAULT NULL,PRIMARY KEY (
id
));
INSERT INTO
t1
VALUES (1,'0'),(2,'NULL'),(3,'false'),(4,NULL),(5,NULL),(6,NULL),(7,''),(8,'0000-00-00 00:00:00'),(9,' ');CREATE TABLE
t2
(id
bigint(64) NOT NULL AUTO_INCREMENT,col1
varchar(511) DEFAULT NULL,PRIMARY KEY (
id
)) ;
INSERT INTO
t2
VALUES (1,''),(2,NULL),(3,NULL),(4,''),(5,NULL),(6,NULL),(7,NULL),(8,''),(9,'-1'),(10,'-0'),(11,'1'),(12,'1'),(13,' '),(14,'0000-00-00 00:00:00');CREATE TABLE
t3
(id
bigint(64) NOT NULL AUTO_INCREMENT,col1
varchar(511) DEFAULT NULL,PRIMARY KEY (
id
));
INSERT INTO
t3
VALUES (15,'0000-00-00 00:00:00'),(16,NULL),(17,NULL),(18,'NULL'),(19,'-0'),(20,NULL),(21,''),(22,'-0');2. What did you expect to see?
Correct Merge Join when transforming hash join to merge join.
3. What did you see instead
mysql> SELECT /+ merge_join(t1, t2, t3)/ t3.col1 FROM (t1 LEFT JOIN t2 ON t1.col1=t2.col1) LEFT JOIN t3 ON t2.col1=t3.col1;
+------+
| col1 |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
11 rows in set (0.00 sec)
mysql> SELECT /+ hash_join(t1, t2, t3)/ t3.col1 FROM (t1 LEFT JOIN t2 ON t1.col1=t2..col1) LEFT JOIN t3 ON t2.col1=t3.col1;
+---------------------+
| col1 |
+---------------------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
| |
| |
| |
| 0000-00-00 00:00:00 |
| NULL |
+---------------------+
11 rows in set (0.00 sec)
4. What is your TiDB version?
mysql> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.4.0
Edition: Community
Git Commit Hash: 55f3b24
Git Branch: heads/refs/tags/v5.4.0
UTC Build Time: 2022-01-25 08:39:26
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
The text was updated successfully, but these errors were encountered: