-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Does not yet work with ORDER BY or LIMIT on the UNION.
- Loading branch information
Showing
6 changed files
with
480 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,134 @@ | ||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) UNION VALUES (1), (3), (1) | ||
---- | ||
1 | ||
2 | ||
3 | ||
|
||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) UNION ALL VALUES (1), (3), (1) | ||
---- | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 | ||
2 | ||
2 | ||
3 | ||
|
||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) INTERSECT VALUES (1), (3), (1) | ||
---- | ||
1 | ||
|
||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) INTERSECT ALL VALUES (1), (3), (1) | ||
---- | ||
1 | ||
1 | ||
|
||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) EXCEPT VALUES (1), (3), (1) | ||
---- | ||
2 | ||
|
||
query I rowsort | ||
VALUES (1), (1), (1), (2), (2) EXCEPT ALL VALUES (1), (3), (1) | ||
---- | ||
1 | ||
2 | ||
2 | ||
|
||
query II rowsort | ||
VALUES (1, 2), (1, 1), (1, 2), (2, 1), (2, 1) UNION VALUES (1, 3), (3, 4), (1, 1) | ||
---- | ||
1 1 | ||
1 2 | ||
1 3 | ||
2 1 | ||
3 4 | ||
|
||
statement ok | ||
CREATE TABLE uniontest ( | ||
k INT, | ||
v INT | ||
) | ||
|
||
statement OK | ||
INSERT INTO uniontest VALUES | ||
(1, 1), | ||
(1, 1), | ||
(1, 1), | ||
(1, 2), | ||
(1, 2), | ||
(2, 1), | ||
(2, 3), | ||
(2, 1) | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 UNION SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
1 | ||
2 | ||
3 | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 UNION ALL SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
1 | ||
1 | ||
1 | ||
1 | ||
1 | ||
2 | ||
2 | ||
3 | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 INTERSECT SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
1 | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 INTERSECT ALL SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
1 | ||
1 | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 EXCEPT SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
2 | ||
|
||
query I rowsort | ||
SELECT v FROM uniontest WHERE k = 1 EXCEPT ALL SELECT v FROM uniontest WHERE k = 2 | ||
---- | ||
1 | ||
2 | ||
2 | ||
|
||
query ITT rowsort | ||
EXPLAIN SELECT v FROM uniontest UNION SELECT k FROM uniontest | ||
---- | ||
0 union - | ||
1 scan uniontest@primary | ||
1 scan uniontest@primary | ||
|
||
query error each UNION query must have the same number of columns: 2 vs 1 | ||
SELECT 1, 2 UNION SELECT 3 | ||
|
||
query error each INTERSECT query must have the same number of columns: 2 vs 1 | ||
SELECT 1, 2 INTERSECT SELECT 3 | ||
|
||
query error each EXCEPT query must have the same number of columns: 2 vs 1 | ||
SELECT 1, 2 EXCEPT SELECT 3 | ||
|
||
query error UNION types int and string cannot be matched | ||
SELECT 1 UNION SELECT '3' | ||
|
||
query error INTERSECT types int and string cannot be matched | ||
SELECT 1 INTERSECT SELECT '3' | ||
|
||
query error EXCEPT types int and string cannot be matched | ||
SELECT 1 EXCEPT SELECT '3' |
Oops, something went wrong.