-
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.
logictest: add testfile to ensure that window functions are vectorized
This commit adds a logic testfile that executes the window functions currently supported by the vectorized engine with `SET vectorize = experimental_always`. This tests that supported window functions can actually be executed in the vectorized engine. Release note: None
- Loading branch information
1 parent
7638c44
commit f1cdf73
Showing
2 changed files
with
247 additions
and
117 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,247 @@ | ||
# LogicTest: local fakedist fakedist-disk 3node-tenant | ||
|
||
# Ensure that all these queries can be executed in the vectorized engine. | ||
statement ok | ||
SET vectorize = experimental_always | ||
|
||
statement ok | ||
CREATE TABLE t (a INT, b INT, c INT PRIMARY KEY) | ||
|
||
statement ok | ||
INSERT INTO t VALUES | ||
(0, 1, 0), | ||
(1, 1, 1), | ||
(0, 2, 2), | ||
(1, 2, 3) | ||
|
||
# We sort the output on all queries with row_number window function to get | ||
# deterministic results. | ||
query III | ||
SELECT a, b, row_number() OVER (ORDER BY a, b) FROM t ORDER BY a, b | ||
---- | ||
0 1 1 | ||
0 2 2 | ||
1 1 3 | ||
1 2 4 | ||
|
||
query III | ||
SELECT a, b, row_number() OVER (PARTITION BY a ORDER BY b) FROM t ORDER BY a, b | ||
---- | ||
0 1 1 | ||
0 2 2 | ||
1 1 1 | ||
1 2 2 | ||
|
||
query III | ||
SELECT a, b, row_number() OVER (PARTITION BY a, b) FROM t ORDER BY a, b | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 1 | ||
1 2 1 | ||
|
||
query III rowsort | ||
SELECT a, b, rank() OVER () FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 1 | ||
1 2 1 | ||
|
||
query III rowsort | ||
SELECT a, b, rank() OVER (ORDER BY a) FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 3 | ||
1 2 3 | ||
|
||
query IIII rowsort | ||
SELECT a, b, c, rank() OVER (PARTITION BY a ORDER BY c) FROM t | ||
---- | ||
0 1 0 1 | ||
0 2 2 2 | ||
1 1 1 1 | ||
1 2 3 2 | ||
|
||
query III rowsort | ||
SELECT a, b, dense_rank() OVER () FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 1 | ||
1 2 1 | ||
|
||
query III rowsort | ||
SELECT a, b, dense_rank() OVER (ORDER BY a) FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 2 | ||
1 2 2 | ||
|
||
query IIII rowsort | ||
SELECT a, b, c, dense_rank() OVER (PARTITION BY a ORDER BY c) FROM t | ||
---- | ||
0 1 0 1 | ||
0 2 2 2 | ||
1 1 1 1 | ||
1 2 3 2 | ||
|
||
query IIIIRR rowsort | ||
SELECT a, b, rank() OVER w, dense_rank() OVER w, percent_rank() OVER w, cume_dist() OVER w FROM t WINDOW w AS () | ||
---- | ||
0 1 1 1 0 1 | ||
1 1 1 1 0 1 | ||
0 2 1 1 0 1 | ||
1 2 1 1 0 1 | ||
|
||
query IIIIRR rowsort | ||
SELECT a, b, rank() OVER w, dense_rank() OVER w, percent_rank() OVER w, cume_dist() OVER w FROM t WINDOW w AS (PARTITION BY a) | ||
---- | ||
0 1 1 1 0 1 | ||
0 2 1 1 0 1 | ||
1 1 1 1 0 1 | ||
1 2 1 1 0 1 | ||
|
||
|
||
query IIIIRR rowsort | ||
SELECT a, b, rank() OVER w, dense_rank() OVER w, percent_rank() OVER w, cume_dist() OVER w FROM t WINDOW w AS (ORDER BY a) | ||
---- | ||
0 1 1 1 0 0.5 | ||
0 2 1 1 0 0.5 | ||
1 1 3 2 0.666666666666667 1 | ||
1 2 3 2 0.666666666666667 1 | ||
|
||
query IIIIRR rowsort | ||
SELECT a, b, rank() OVER w, dense_rank() OVER w, percent_rank() OVER w, cume_dist() OVER w FROM t WINDOW w AS (PARTITION BY a ORDER BY b) | ||
---- | ||
0 1 1 1 0 0.5 | ||
0 2 2 2 1 1 | ||
1 1 1 1 0 0.5 | ||
1 2 2 2 1 1 | ||
|
||
query IIR rowsort | ||
SELECT a, b, percent_rank() OVER () FROM t | ||
---- | ||
0 1 0 | ||
1 1 0 | ||
0 2 0 | ||
1 2 0 | ||
|
||
query IIR rowsort | ||
SELECT a, b, percent_rank() OVER (ORDER BY a) FROM t | ||
---- | ||
0 1 0 | ||
0 2 0 | ||
1 1 0.666666666666667 | ||
1 2 0.666666666666667 | ||
|
||
query IIIR rowsort | ||
SELECT a, b, c, percent_rank() OVER (PARTITION BY a ORDER BY c) FROM t | ||
---- | ||
0 1 0 0 | ||
0 2 2 1 | ||
1 1 1 0 | ||
1 2 3 1 | ||
|
||
query IIR rowsort | ||
SELECT a, b, cume_dist() OVER () FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 1 | ||
1 2 1 | ||
|
||
query IIR rowsort | ||
SELECT a, b, cume_dist() OVER (ORDER BY a) FROM t | ||
---- | ||
0 1 0.5 | ||
0 2 0.5 | ||
1 1 1 | ||
1 2 1 | ||
|
||
query IIIR rowsort | ||
SELECT a, b, c, cume_dist() OVER (PARTITION BY a ORDER BY c) FROM t | ||
---- | ||
0 1 0 0.5 | ||
0 2 2 1 | ||
1 1 1 0.5 | ||
1 2 3 1 | ||
|
||
query III rowsort | ||
SELECT a, b, ntile(2) OVER (ORDER BY a, b) FROM t | ||
---- | ||
0 1 1 | ||
0 2 1 | ||
1 1 2 | ||
1 2 2 | ||
|
||
query IIII rowsort | ||
SELECT a, b, c, ntile(2) OVER (PARTITION BY a ORDER BY c) FROM t | ||
---- | ||
0 1 0 1 | ||
0 2 2 2 | ||
1 1 1 1 | ||
1 2 3 2 | ||
|
||
query IIII rowsort | ||
SELECT a, b, lag(a, b) OVER w, lead(a, b) OVER w FROM t WINDOW w AS (ORDER BY a, b) | ||
---- | ||
0 1 NULL 0 | ||
0 2 NULL 1 | ||
1 1 0 1 | ||
1 2 0 NULL | ||
|
||
query IIIII rowsort | ||
SELECT a, b, c, lag(a, b) OVER w, lead(a, b) OVER w FROM t WINDOW w AS (PARTITION BY a ORDER BY c) | ||
---- | ||
0 1 0 NULL 0 | ||
0 2 2 NULL NULL | ||
1 1 1 NULL 1 | ||
1 2 3 NULL NULL | ||
|
||
query IIIIII rowsort | ||
SELECT a, b, c, first_value(a) OVER w, last_value(a) OVER w, nth_value(a, b) OVER w | ||
FROM t WINDOW w AS (ORDER BY c, b) | ||
---- | ||
0 1 0 0 0 0 | ||
1 1 1 0 1 0 | ||
0 2 2 0 0 1 | ||
1 2 3 0 1 1 | ||
|
||
query IIIIII rowsort | ||
SELECT a, b, c, first_value(a) OVER w, last_value(a) OVER w, nth_value(a, b) OVER w | ||
FROM t WINDOW w AS (PARTITION BY a ORDER BY c) | ||
---- | ||
0 1 0 0 0 0 | ||
0 2 2 0 0 0 | ||
1 1 1 1 1 1 | ||
1 2 3 1 1 1 | ||
|
||
query IIIIII rowsort | ||
SELECT a, b, c, first_value(a) OVER w, last_value(a) OVER w, nth_value(a, b) OVER w | ||
FROM t WINDOW w AS (ORDER BY c, b ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) | ||
---- | ||
0 1 0 0 0 0 | ||
1 1 1 0 1 0 | ||
0 2 2 0 0 1 | ||
1 2 3 0 1 1 | ||
|
||
query IIIIII rowsort | ||
SELECT a, b, c, first_value(a) OVER w, last_value(a) OVER w, nth_value(a, b) OVER w | ||
FROM t WINDOW w AS (ORDER BY c, b GROUPS BETWEEN 5 PRECEDING AND CURRENT ROW) | ||
---- | ||
0 1 0 0 0 0 | ||
1 1 1 0 1 0 | ||
0 2 2 0 0 1 | ||
1 2 3 0 1 1 | ||
|
||
query IIII rowsort | ||
SELECT c, first_value(c) OVER w, last_value(c) OVER w, nth_value(c, 2) OVER w | ||
FROM t WINDOW w AS (ORDER BY c RANGE BETWEEN 5 PRECEDING AND CURRENT ROW) | ||
---- | ||
0 0 0 NULL | ||
1 0 1 1 | ||
2 0 2 1 | ||
3 0 3 1 |
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