Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: Support IN conditions with a subquery
Support IN exprs with subqueries on the RHS in the WHERE clause of queries, by compiling them to an INNER JOIN with a DISTINCT on the rhs Release-Note-Core: Add support for queries with a WHERE clause containing IN with subqueries on the right-hand side Change-Id: Iddb8a385a01b423272c0ad8c0197324538217269 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/5522 Tested-by: Buildkite CI Reviewed-by: Dan Wilbanks <dan@readyset.io>
- Loading branch information
1 parent
7a0aa4c
commit 380b258
Showing
3 changed files
with
133 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
statement ok | ||
create table t1 (x int, y int); | ||
|
||
statement ok | ||
create table t2 (x int, y int); | ||
|
||
statement ok | ||
insert into t1 (x, y) | ||
values | ||
(1, 1), | ||
(2, 2), | ||
(3, 3); | ||
|
||
statement ok | ||
insert into t2 (x, y) | ||
values | ||
(1, 1), | ||
(1, 1); | ||
|
||
|
||
query I nosort | ||
select count(*) from t1 where x in (select x from t2); | ||
---- | ||
1 | ||
|
||
|
||
query I nosort | ||
select y from t1 where x in (select x + 1 from t2 where y = 1); | ||
---- | ||
2 | ||
|
||
|
||
query I nosort | ||
select y from t1 where (x + 1) in (select x + 1 from t2 where y = 1); | ||
---- | ||
1 | ||
|
||
|
||
query I rowsort | ||
select y from t1 | ||
where | ||
(x + 1) in (select x + 1 from t2 where y = 1) | ||
OR y = 2 | ||
---- | ||
1 | ||
2 |
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