-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complex Expression handling for uncorrelated IN and NOT IN subqueries (…
…#16439) Signed-off-by: Manan Gupta <manan@planetscale.com>
- Loading branch information
1 parent
00cba23
commit 2e847cd
Showing
3 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
go/test/endtoend/vtgate/vitess_tester/subquery/subquery.test
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,42 @@ | ||
create table t1 | ||
( | ||
id1 bigint, | ||
id2 bigint, | ||
primary key (id1) | ||
) Engine = InnoDB; | ||
|
||
create table t2 | ||
( | ||
id3 bigint, | ||
id4 bigint, | ||
primary key (id3) | ||
) Engine = InnoDB; | ||
|
||
INSERT INTO t1 (id1, id2) VALUES | ||
(0, 0), | ||
(1, 1), | ||
(2, 2), | ||
(3, 3), | ||
(4, 4); | ||
|
||
INSERT INTO t2 (id3, id4) VALUES | ||
(0, 0), | ||
(1, 1); | ||
|
||
# Aggregation query with multiple expressions one of which is an IN subquery. | ||
SELECT count(*) FROM t1 WHERE id1 = 0 AND id1 IN (SELECT id4 FROM t2); | ||
# Aggregation query with a complex expression that has an IN subquery. | ||
SELECT count(*) FROM t1 WHERE id1 = 2 OR id1 IN (SELECT id4 FROM t2); | ||
# Aggregation query with multiple expressions one of which is an IN subquery that returns empty results. | ||
SELECT count(*) FROM t1 WHERE id1 = 0 AND id1 IN (SELECT id4 FROM t2 where id4 = 3); | ||
# Aggregation query with a complex expression that has an IN subquery that returns empty results. | ||
SELECT count(*) FROM t1 WHERE id1 = 2 OR id1 IN (SELECT id4 FROM t2 where id4 = 3); | ||
|
||
# Aggregation query with multiple expressions one of which is an NOT IN subquery. | ||
SELECT count(*) FROM t1 WHERE id1 = 2 AND id1 NOT IN (SELECT id4 FROM t2); | ||
# Aggregation query with a complex expression that has an NOT IN subquery. | ||
SELECT count(*) FROM t1 WHERE id1 = 0 OR id1 NOT IN (SELECT id4 FROM t2); | ||
# Aggregation query with multiple expressions one of which is an NOT IN subquery that returns empty results. | ||
SELECT count(*) FROM t1 WHERE id1 = 2 AND id1 NOT IN (SELECT id4 FROM t2 where id4 = 3); | ||
# Aggregation query with a complex expression that has an NOT IN subquery that returns empty results. | ||
SELECT count(*) FROM t1 WHERE id1 = 0 OR id1 NOT IN (SELECT id4 FROM t2 where id4 = 3); |
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