8b98560d6e
FossilOrigin-Name: ceaf798ea09184bc0e7d3dcf3ad4d909d2e4e7018754a8417a813f33010140a7
190 lines
6.1 KiB
Plaintext
190 lines
6.1 KiB
Plaintext
# 2018 June 04
|
|
#
|
|
# The author disclaims copyright to this source code. In place of
|
|
# a legal notice, here is a blessing:
|
|
#
|
|
# May you do good and not evil.
|
|
# May you find forgiveness for yourself and forgive others.
|
|
# May you share freely, never taking more than you give.
|
|
#
|
|
#***********************************************************************
|
|
# This file implements regression tests for SQLite library.
|
|
#
|
|
|
|
####################################################
|
|
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
|
|
####################################################
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
set testprefix window4
|
|
|
|
do_execsql_test 1.0 {
|
|
DROP TABLE IF EXISTS t3;
|
|
CREATE TABLE t3(a TEXT PRIMARY KEY);
|
|
INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
|
|
INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
|
|
} {}
|
|
|
|
do_execsql_test 1.1 {
|
|
SELECT a, ntile(1) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 1 d 1 e 1 f 1 g 1 h 1 i 1 j 1}
|
|
|
|
do_execsql_test 1.2 {
|
|
SELECT a, ntile(2) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 1 d 1 e 1 f 2 g 2 h 2 i 2 j 2}
|
|
|
|
do_execsql_test 1.3 {
|
|
SELECT a, ntile(3) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 1 d 1 e 2 f 2 g 2 h 3 i 3 j 3}
|
|
|
|
do_execsql_test 1.4 {
|
|
SELECT a, ntile(4) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 1 d 2 e 2 f 2 g 3 h 3 i 4 j 4}
|
|
|
|
do_execsql_test 1.5 {
|
|
SELECT a, ntile(5) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 5}
|
|
|
|
do_execsql_test 1.6 {
|
|
SELECT a, ntile(6) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 6}
|
|
|
|
do_execsql_test 1.7 {
|
|
SELECT a, ntile(7) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 5 i 6 j 7}
|
|
|
|
do_execsql_test 1.8 {
|
|
SELECT a, ntile(8) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 2 d 2 e 3 f 4 g 5 h 6 i 7 j 8}
|
|
|
|
do_execsql_test 1.9 {
|
|
SELECT a, ntile(9) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 1 c 2 d 3 e 4 f 5 g 6 h 7 i 8 j 9}
|
|
|
|
do_execsql_test 1.10 {
|
|
SELECT a, ntile(10) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.11 {
|
|
SELECT a, ntile(11) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.12 {
|
|
SELECT a, ntile(12) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.13 {
|
|
SELECT a, ntile(13) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.14 {
|
|
SELECT a, ntile(14) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.15 {
|
|
SELECT a, ntile(15) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.16 {
|
|
SELECT a, ntile(16) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.17 {
|
|
SELECT a, ntile(17) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.18 {
|
|
SELECT a, ntile(18) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 1.19 {
|
|
SELECT a, ntile(19) OVER (ORDER BY a) FROM t3
|
|
} {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
|
|
|
|
do_execsql_test 2.0 {
|
|
DROP TABLE IF EXISTS t4;
|
|
CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
|
|
INSERT INTO t4 VALUES(1, 'A', 9);
|
|
INSERT INTO t4 VALUES(2, 'B', 3);
|
|
INSERT INTO t4 VALUES(3, 'C', 2);
|
|
INSERT INTO t4 VALUES(4, 'D', 10);
|
|
INSERT INTO t4 VALUES(5, 'E', 5);
|
|
INSERT INTO t4 VALUES(6, 'F', 1);
|
|
INSERT INTO t4 VALUES(7, 'G', 1);
|
|
INSERT INTO t4 VALUES(8, 'H', 2);
|
|
INSERT INTO t4 VALUES(9, 'I', 10);
|
|
INSERT INTO t4 VALUES(10, 'J', 4);
|
|
} {}
|
|
|
|
do_execsql_test 2.1 {
|
|
SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
|
|
} {1 {} 2 {} 3 B 4 {} 5 E 6 A 7 A 8 B 9 {} 10 D}
|
|
|
|
do_execsql_test 2.2.1 {
|
|
SELECT a, lead(b) OVER (ORDER BY a) FROM t4
|
|
} {1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 I 9 J 10 {}}
|
|
|
|
do_execsql_test 2.2.2 {
|
|
SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
|
|
} {1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9 {} 10 {}}
|
|
|
|
do_execsql_test 2.2.3 {
|
|
SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
|
|
} {1 D 2 E 3 F 4 G 5 H 6 I 7 J 8 abc 9 abc 10 abc}
|
|
|
|
do_execsql_test 2.3.1 {
|
|
SELECT a, lag(b) OVER (ORDER BY a) FROM t4
|
|
} {1 {} 2 A 3 B 4 C 5 D 6 E 7 F 8 G 9 H 10 I}
|
|
|
|
do_execsql_test 2.3.2 {
|
|
SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
|
|
} {1 {} 2 {} 3 A 4 B 5 C 6 D 7 E 8 F 9 G 10 H}
|
|
|
|
do_execsql_test 2.3.3 {
|
|
SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
|
|
} {1 abc 2 abc 3 abc 4 A 5 B 6 C 7 D 8 E 9 F 10 G}
|
|
|
|
do_execsql_test 2.4.1 {
|
|
SELECT group_concat(b, '.') OVER (
|
|
ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
|
) FROM t4
|
|
} {A.B.C.D.E.F.G.H.I.J B.C.D.E.F.G.H.I.J C.D.E.F.G.H.I.J D.E.F.G.H.I.J E.F.G.H.I.J F.G.H.I.J G.H.I.J H.I.J I.J J}
|
|
|
|
do_execsql_test 3.0 {
|
|
DROP TABLE IF EXISTS t5;
|
|
CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
|
|
INSERT INTO t5 VALUES(1, 'A', 'one', 5);
|
|
INSERT INTO t5 VALUES(2, 'B', 'two', 4);
|
|
INSERT INTO t5 VALUES(3, 'A', 'three', 3);
|
|
INSERT INTO t5 VALUES(4, 'B', 'four', 2);
|
|
INSERT INTO t5 VALUES(5, 'A', 'five', 1);
|
|
} {}
|
|
|
|
do_execsql_test 3.1 {
|
|
SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
|
|
} {1 {} 3 five 5 one 2 two 4 three}
|
|
|
|
do_execsql_test 3.2 {
|
|
SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
|
|
} {1 {} 3 {} 5 one 2 {} 4 four}
|
|
|
|
do_execsql_test 3.3 {
|
|
SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
|
|
WINDOW abc AS (ORDER BY a),
|
|
def AS (ORDER BY a DESC)
|
|
ORDER BY a;
|
|
} {1 1 5 2 2 4 3 3 3 4 4 2 5 5 1}
|
|
|
|
explain_i {
|
|
SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
|
|
WINDOW w AS (ORDER BY a)
|
|
}
|
|
breakpoint
|
|
do_execsql_test 3.4 {
|
|
SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
|
|
WINDOW w AS (ORDER BY a)
|
|
} {1 {} 2 2 3 2 4 4 5 4}
|
|
|
|
finish_test
|