1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add support for chaining of WINDOW definitions.

FossilOrigin-Name: c155125fd5dddb438c09d40f5137c47d88defb7a6ede4261f09d7bdaad250d37
This commit is contained in:
dan
2019-02-16 17:27:51 +00:00
parent 9c7e44cddd
commit e7c9ca41b2
8 changed files with 1934 additions and 1346 deletions

View File

@ -21,7 +21,6 @@ execsql_test 1.0 {
DROP TABLE IF EXISTS t2;
CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER);
INSERT INTO t2(a, b) VALUES
(1,0), (2,74), (3,41), (4,74), (5,23), (6,99), (7,26), (8,33), (9,2),
(10,89), (11,81), (12,96), (13,59), (14,38), (15,68), (16,39), (17,62),
(18,91), (19,46), (20,6), (21,99), (22,97), (23,27), (24,46), (25,78),
(26,54), (27,97), (28,8), (29,67), (30,29), (31,93), (32,84), (33,77),
@ -307,6 +306,28 @@ foreach {tn window} {
SELECT string_agg(CAST(b AS TEXT), '.') OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
"
execsql_test 1.$tn.14.7 "
SELECT string_agg(CAST(b AS TEXT), '.') OVER (win1 ORDER BY b%10 $window)
FROM t2
WINDOW win1 AS (PARTITION BY b%2,a)
ORDER BY 1
"
execsql_test 1.$tn.14.8 "
SELECT string_agg(CAST(b AS TEXT), '.') OVER (win1 $window)
FROM t2
WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10)
ORDER BY 1
"
execsql_test 1.$tn.14.9 "
SELECT string_agg(CAST(b AS TEXT), '.') OVER win2
FROM t2
WINDOW win1 AS (PARTITION BY b%2,a ORDER BY b%10),
win2 AS (win1 $window)
ORDER BY 1
"
execsql_test 1.$tn.15.1 "
SELECT count(*) OVER win, string_agg(CAST(b AS TEXT), '.')
FILTER (WHERE a%2=0) OVER win FROM t2