-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BugFix] fix mysql external table clause (#50901)
(cherry picked from commit 9dbe691)
- Loading branch information
1 parent
f4c3bcd
commit 1cd5dc2
Showing
3 changed files
with
169 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
-- name: testExternalMysqlCaluse | ||
create database db_${uuid0}; | ||
-- result: | ||
-- !result | ||
use db_${uuid0}; | ||
-- result: | ||
-- !result | ||
CREATE TABLE `t00` ( | ||
`id` int, | ||
`s` string | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`id`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1", | ||
"enable_persistent_index" = "false", | ||
"replicated_storage" = "false", | ||
"compression" = "LZ4" | ||
); | ||
-- result: | ||
-- !result | ||
insert into t00 values(1, "hello"), (2, "world"), (3, null); | ||
-- result: | ||
-- !result | ||
CREATE EXTERNAL TABLE mysql_ext | ||
( | ||
`id` int, | ||
`s` string | ||
) | ||
ENGINE=mysql | ||
PROPERTIES | ||
( | ||
"host" = "${mysql_host}", | ||
"port" = "${mysql_port}", | ||
"user" = "${mysql_user}", | ||
"password" = "${mysql_password}", | ||
"database" = "db_${uuid0}", | ||
"table" = "t00" | ||
); | ||
-- result: | ||
-- !result | ||
set cbo_derive_join_is_null_predicate = true; | ||
-- result: | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id = 3; | ||
-- result: | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2, 3); | ||
-- result: | ||
1 hello 1 hello | ||
2 world 2 world | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2); | ||
-- result: | ||
1 hello 1 hello | ||
2 world 2 world | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1); | ||
-- result: | ||
1 hello 1 hello | ||
-- !result | ||
set cbo_derive_join_is_null_predicate = false; | ||
-- result: | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id = 3; | ||
-- result: | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2, 3); | ||
-- result: | ||
1 hello 1 hello | ||
2 world 2 world | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2); | ||
-- result: | ||
1 hello 1 hello | ||
2 world 2 world | ||
-- !result | ||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1); | ||
-- result: | ||
1 hello 1 hello | ||
-- !result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- name: testExternalMysqlCaluse | ||
|
||
create database db_${uuid0}; | ||
use db_${uuid0}; | ||
|
||
CREATE TABLE `t00` ( | ||
`id` int, | ||
`s` string | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`id`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1", | ||
"enable_persistent_index" = "false", | ||
"replicated_storage" = "false", | ||
"compression" = "LZ4" | ||
); | ||
|
||
insert into t00 values(1, "hello"), (2, "world"), (3, null); | ||
|
||
CREATE EXTERNAL TABLE mysql_ext | ||
( | ||
`id` int, | ||
`s` string | ||
) | ||
ENGINE=mysql | ||
PROPERTIES | ||
( | ||
"host" = "${mysql_host}", | ||
"port" = "${mysql_port}", | ||
"user" = "${mysql_user}", | ||
"password" = "${mysql_password}", | ||
"database" = "db_${uuid0}", | ||
"table" = "t00" | ||
); | ||
|
||
set cbo_derive_join_is_null_predicate = true; | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id = 3; | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2, 3); | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2); | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1); | ||
|
||
|
||
set cbo_derive_join_is_null_predicate = false; | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id = 3; | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2, 3); | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1, 2); | ||
|
||
select * from mysql_ext x inner join t00 on x.s = t00.s where t00.id in (1); | ||
|