should be it
This commit is contained in:
169
external/duckdb/test/sql/window/test_basic_window.test
vendored
Normal file
169
external/duckdb/test/sql/window/test_basic_window.test
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
# name: test/sql/window/test_basic_window.test
|
||||
# description: Most basic window function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date)
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15')
|
||||
|
||||
# basic example from postgres' window.sql
|
||||
query TIIR
|
||||
SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname ORDER BY empno) FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 7 4200 4200.000000
|
||||
develop 8 6000 10200.000000
|
||||
develop 9 4500 14700.000000
|
||||
develop 10 5200 19900.000000
|
||||
develop 11 5200 25100.000000
|
||||
personnel 2 3900 3900.000000
|
||||
personnel 5 3500 7400.000000
|
||||
sales 1 5000 5000.000000
|
||||
sales 3 4800 9800.000000
|
||||
sales 4 4800 14600.000000
|
||||
|
||||
# sum
|
||||
query R
|
||||
SELECT sum(salary) OVER (PARTITION BY depname ORDER BY salary) ss FROM empsalary ORDER BY depname, ss
|
||||
----
|
||||
4200.000000
|
||||
8700.000000
|
||||
19100.000000
|
||||
19100.000000
|
||||
25100.000000
|
||||
3500.000000
|
||||
7400.000000
|
||||
9600.000000
|
||||
9600.000000
|
||||
14600.000000
|
||||
|
||||
# row_number
|
||||
query I
|
||||
SELECT row_number() OVER (PARTITION BY depname ORDER BY salary) rn FROM empsalary ORDER BY depname, rn
|
||||
----
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
# first_value
|
||||
query II
|
||||
SELECT empno, first_value(empno) OVER (PARTITION BY depname ORDER BY empno) fv FROM empsalary ORDER BY 2 DESC, 1 ASC
|
||||
----
|
||||
7 7
|
||||
8 7
|
||||
9 7
|
||||
10 7
|
||||
11 7
|
||||
2 2
|
||||
5 2
|
||||
1 1
|
||||
3 1
|
||||
4 1
|
||||
|
||||
# last_value
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
last_value(empno) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 11
|
||||
develop 8 11
|
||||
develop 9 11
|
||||
develop 10 11
|
||||
develop 11 11
|
||||
personnel 2 5
|
||||
personnel 5 5
|
||||
sales 1 4
|
||||
sales 3 4
|
||||
sales 4 4
|
||||
|
||||
# rank_dense
|
||||
query TII
|
||||
SELECT depname, salary, dense_rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary order by depname, salary
|
||||
----
|
||||
develop 4200 1
|
||||
develop 4500 2
|
||||
develop 5200 3
|
||||
develop 5200 3
|
||||
develop 6000 4
|
||||
personnel 3500 1
|
||||
personnel 3900 2
|
||||
sales 4800 1
|
||||
sales 4800 1
|
||||
sales 5000 2
|
||||
|
||||
# rank
|
||||
query TII
|
||||
SELECT depname, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary order by depname, salary
|
||||
----
|
||||
develop 4200 1
|
||||
develop 4500 2
|
||||
develop 5200 3
|
||||
develop 5200 3
|
||||
develop 6000 5
|
||||
personnel 3500 1
|
||||
personnel 3900 2
|
||||
sales 4800 1
|
||||
sales 4800 1
|
||||
sales 5000 3
|
||||
|
||||
# min/max/avg
|
||||
query TIIR
|
||||
SELECT depname, min(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m1, max(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m2, AVG(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m3 FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 4200 4200 4200.000000
|
||||
develop 4200 6000 5020.000000
|
||||
develop 4200 4500 4350.000000
|
||||
develop 4200 5200 4633.333333
|
||||
develop 4200 5200 4775.000000
|
||||
personnel 3500 3900 3700.000000
|
||||
personnel 3500 3500 3500.000000
|
||||
sales 4800 5000 4866.666667
|
||||
sales 4800 4800 4800.000000
|
||||
sales 4800 4800 4800.000000
|
||||
|
||||
# stddev_pop
|
||||
query TR
|
||||
SELECT depname, STDDEV_POP(salary) OVER (PARTITION BY depname ORDER BY salary, empno) s FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 0.000000
|
||||
develop 627.375486
|
||||
develop 150.000000
|
||||
develop 418.993503
|
||||
develop 438.035387
|
||||
personnel 200.000000
|
||||
personnel 0.000000
|
||||
sales 94.280904
|
||||
sales 0.000000
|
||||
sales 0.000000
|
||||
|
||||
# covar_pop
|
||||
query TR
|
||||
SELECT depname, COVAR_POP(salary, empno) OVER (PARTITION BY depname ORDER BY salary, empno) c FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 0.000000
|
||||
develop 240.000000
|
||||
develop 150.000000
|
||||
develop 477.777778
|
||||
develop 606.250000
|
||||
personnel -300.000000
|
||||
personnel 0.000000
|
||||
sales -111.111111
|
||||
sales 0.000000
|
||||
sales 0.000000
|
||||
|
||||
122
external/duckdb/test/sql/window/test_boundary_expr.test
vendored
Normal file
122
external/duckdb/test/sql/window/test_boundary_expr.test
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
# name: test/sql/window/test_boundary_expr.test
|
||||
# description: Expressions in boundaries
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tenk1 ( unique1 int4, unique2 int4, two int4, four int4, ten int4, twenty int4, hundred int4, thousand int4, twothousand int4, fivethous int4, tenthous int4, odd int4, even int4, stringu1 string, stringu2 string, string4 string )
|
||||
|
||||
statement ok
|
||||
insert into tenk1 values (4, 1621, 0, 0, 4, 4, 4, 4, 4, 4, 4, 8 ,9 ,'EAAAAA', 'JKCAAA', 'HHHHxx'), (2, 2716, 0, 2, 2, 2, 2, 2, 2, 2, 2, 4 ,5 ,'CAAAAA', 'MAEAAA', 'AAAAxx'), (1, 2838, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ,3 ,'BAAAAA', 'EFEAAA', 'OOOOxx'), (6, 2855, 0, 2, 6, 6, 6, 6, 6, 6, 6, 12 ,13 ,'GAAAAA', 'VFEAAA', 'VVVVxx'), (9, 4463, 1, 1, 9, 9, 9, 9, 9, 9, 9, 18 ,19 ,'JAAAAA', 'RPGAAA', 'VVVVxx'),(8, 5435, 0, 0, 8, 8, 8, 8, 8, 8, 8, 16 ,17 ,'IAAAAA', 'BBIAAA', 'VVVVxx'), (5, 5557, 1, 1, 5, 5, 5, 5, 5, 5, 5, 10 ,11,'FAAAAA', 'TFIAAA', 'HHHHxx'), (3, 5679, 1, 3, 3, 3, 3, 3, 3, 3, 3, 6 ,7 ,'DAAAAA', 'LKIAAA', 'VVVVxx'), (7, 8518, 1,3, 7, 7, 7, 7, 7, 7, 7, 14 ,15 ,'HAAAAA', 'QPMAAA', 'OOOOxx'), (0, 9998, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,1 ,'AAAAAA','OUOAAA', 'OOOOxx')
|
||||
|
||||
query R
|
||||
SELECT sum(unique1) over (order by unique1 rows between 2 preceding and 2 following) su FROM tenk1 order by unique1
|
||||
----
|
||||
3.000000
|
||||
6.000000
|
||||
10.000000
|
||||
15.000000
|
||||
20.000000
|
||||
25.000000
|
||||
30.000000
|
||||
35.000000
|
||||
30.000000
|
||||
24.000000
|
||||
|
||||
query R
|
||||
SELECT sum(unique1) over (order by unique1 rows between 2 preceding and 1 preceding) su FROM tenk1 order by unique1
|
||||
----
|
||||
NULL
|
||||
0.000000
|
||||
1.000000
|
||||
3.000000
|
||||
5.000000
|
||||
7.000000
|
||||
9.000000
|
||||
11.000000
|
||||
13.000000
|
||||
15.000000
|
||||
|
||||
query R
|
||||
SELECT sum(unique1) over (order by unique1 rows between 1 following and 3 following) su FROM tenk1 order by unique1
|
||||
----
|
||||
6.000000
|
||||
9.000000
|
||||
12.000000
|
||||
15.000000
|
||||
18.000000
|
||||
21.000000
|
||||
24.000000
|
||||
17.000000
|
||||
9.000000
|
||||
NULL
|
||||
|
||||
query R
|
||||
SELECT sum(unique1) over (order by unique1 rows between unbounded preceding and 1 following) su FROM tenk1 order by unique1
|
||||
----
|
||||
1.000000
|
||||
3.000000
|
||||
6.000000
|
||||
10.000000
|
||||
15.000000
|
||||
21.000000
|
||||
28.000000
|
||||
36.000000
|
||||
45.000000
|
||||
45.000000
|
||||
|
||||
# Frame starts past partition end
|
||||
query R
|
||||
SELECT sum(unique1) over (order by unique1 rows between 5 following and 10 following) su FROM tenk1 order by unique1
|
||||
----
|
||||
35
|
||||
30
|
||||
24
|
||||
17
|
||||
9
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
# Issue 1472
|
||||
|
||||
statement ok
|
||||
create table issue1472 (permno real, date date, ret real);
|
||||
|
||||
statement ok
|
||||
insert into issue1472 values
|
||||
(10000.0, '1986-02-28'::date, -0.2571428716182709),
|
||||
(10000.0, '1986-03-31'::date, 0.36538460850715637),
|
||||
(10000.0, '1986-04-30'::date, -0.09859155118465424),
|
||||
(10000.0, '1986-05-30'::date, -0.22265625),
|
||||
(10000.0, '1986-06-30'::date, -0.005025125574320555)
|
||||
;
|
||||
|
||||
query RRR
|
||||
select permno,
|
||||
sum(log(ret+1)) over (PARTITION BY permno ORDER BY date rows between 12 preceding and 2 preceding),
|
||||
ret
|
||||
from issue1472
|
||||
ORDER BY permno, date;
|
||||
----
|
||||
10000.0 NULL -0.2571428716182709
|
||||
10000.0 NULL 0.36538460850715637
|
||||
10000.0 -0.12909470484217817 -0.09859155118465424
|
||||
10000.0 0.006160298054551344 -0.22265625
|
||||
10000.0 -0.038918077590690346 -0.005025125574320555
|
||||
|
||||
# Issue #1697
|
||||
statement ok
|
||||
create table issue1697 as
|
||||
select mod(b, 100) as a, b from (select b from range(10000) tbl(b)) t
|
||||
|
||||
statement ok
|
||||
select avg(a) over (
|
||||
order by b asc
|
||||
rows between mod(b * 1023, 11) preceding and 23 - mod(b * 1023, 11) following)
|
||||
from issue1697
|
||||
|
||||
30
external/duckdb/test/sql/window/test_constant_orderby.test
vendored
Normal file
30
external/duckdb/test/sql/window/test_constant_orderby.test
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: test/sql/window/test_constant_orderby.test
|
||||
# description: Constant window aggregation functionality.
|
||||
# group: [window]
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
call dbgen(sf=0.01);
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
l_orderkey,
|
||||
l_shipmode,
|
||||
l_linenumber,
|
||||
mode(l_linenumber ORDER BY l_linenumber DESC) over w AS l_mode,
|
||||
FROM lineitem
|
||||
WINDOW w AS (partition by l_shipmode)
|
||||
ORDER BY ALL
|
||||
LIMIT 10
|
||||
----
|
||||
1 AIR 4 1
|
||||
1 FOB 5 1
|
||||
1 MAIL 2 1
|
||||
1 MAIL 6 1
|
||||
1 REG AIR 3 1
|
||||
1 TRUCK 1 1
|
||||
2 RAIL 1 1
|
||||
3 AIR 1 1
|
||||
3 FOB 5 1
|
||||
3 RAIL 2 1
|
||||
53
external/duckdb/test/sql/window/test_cume_dist_orderby.test
vendored
Normal file
53
external/duckdb/test/sql/window/test_cume_dist_orderby.test
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# name: test/sql/window/test_cume_dist_orderby.test
|
||||
# description: Test argument ordering for CUME_DIST
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
i,
|
||||
(i * 29) % 11 AS outside,
|
||||
i // 2 AS inside,
|
||||
cume_dist(ORDER BY inside DESC) OVER w AS cd,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY outside
|
||||
)
|
||||
ORDER BY inside DESC, i
|
||||
----
|
||||
8 1 4 0.5
|
||||
9 8 4 0.25
|
||||
6 9 3 0.4444444444444444
|
||||
7 5 3 0.4
|
||||
4 6 2 0.6666666666666666
|
||||
5 2 2 0.6666666666666666
|
||||
2 3 1 0.75
|
||||
3 10 1 0.8
|
||||
0 0 0 1.0
|
||||
1 7 0 1.0
|
||||
|
||||
# Test moving frame with identical orderings
|
||||
query III
|
||||
SELECT
|
||||
i,
|
||||
i // 2 AS inside,
|
||||
cume_dist(ORDER BY i // 2) OVER w AS cd,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
)
|
||||
ORDER BY 1;
|
||||
----
|
||||
0 0 0.5
|
||||
1 0 0.4
|
||||
2 1 0.6666666666666666
|
||||
3 1 0.5714285714285714
|
||||
4 2 0.7142857142857143
|
||||
5 2 0.5714285714285714
|
||||
6 3 0.7142857142857143
|
||||
7 3 0.6666666666666666
|
||||
8 4 1.0
|
||||
9 4 1.0
|
||||
40
external/duckdb/test/sql/window/test_custom_spooling.test_slow
vendored
Normal file
40
external/duckdb/test/sql/window/test_custom_spooling.test_slow
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# name: test/sql/window/test_custom_spooling.test_slow
|
||||
# description: Validate spooling of custom window functions.
|
||||
# group: [window]
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
call dbgen(sf=0.1);
|
||||
|
||||
statement ok
|
||||
PRAGMA temp_directory='__TEST_DIR__/window_spooling'
|
||||
|
||||
# Force paging
|
||||
statement ok
|
||||
PRAGMA memory_limit='100MB'
|
||||
|
||||
# Limit threads to improve stability
|
||||
statement ok
|
||||
PRAGMA threads=4;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# MODE is very unstable on this data
|
||||
query III
|
||||
SELECT SUM(s), SUM(q), SUM(m)
|
||||
FROM (
|
||||
SELECT
|
||||
SUM(l_extendedprice) OVER w AS s,
|
||||
QUANTILE(l_extendedprice, 0.5) OVER w AS q,
|
||||
MAD(l_extendedprice) OVER w AS m,
|
||||
FROM lineitem
|
||||
WINDOW w AS (
|
||||
PARTITION BY l_suppkey
|
||||
ORDER BY l_shipdate, l_orderkey, l_linenumber
|
||||
ROWS BETWEEN 20 PRECEDING AND 20 FOLLOWING
|
||||
)
|
||||
) t;
|
||||
----
|
||||
871183083803.67 20718441622.70 9873496927.55
|
||||
213
external/duckdb/test/sql/window/test_dense_rank.test
vendored
Normal file
213
external/duckdb/test/sql/window/test_dense_rank.test
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
# name: test/sql/window/test_dense_rank.test
|
||||
# description: Test DENSE_RANK state computations
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Multiple chunks, single partition
|
||||
query IIIII
|
||||
WITH t AS (
|
||||
SELECT i, DENSE_RANK() OVER (ORDER BY i % 50) AS d
|
||||
FROM range(3000) tbl(i)
|
||||
), w AS (
|
||||
SELECT d, COUNT(*) as c
|
||||
FROM t
|
||||
GROUP BY ALL
|
||||
)
|
||||
SELECT COUNT(*), MIN(d), MAX(d), MIN(c), MAX(c)
|
||||
FROM w
|
||||
----
|
||||
50 1 50 60 60
|
||||
|
||||
# Multiple chunks, multiple partitions
|
||||
query IIIII
|
||||
WITH t AS (
|
||||
SELECT i, DENSE_RANK() OVER (PARTITION BY i // 3000 ORDER BY i % 50) AS d
|
||||
FROM range(9000) tbl(i)
|
||||
), w AS (
|
||||
SELECT d, COUNT(*) as c
|
||||
FROM t
|
||||
GROUP BY ALL
|
||||
)
|
||||
SELECT COUNT(*), MIN(d), MAX(d), MIN(c), MAX(c)
|
||||
FROM w
|
||||
----
|
||||
50 1 50 180 180
|
||||
|
||||
statement ok
|
||||
CREATE TABLE issue9416(idx VARCHAR, source VARCHAR, project VARCHAR, specimen VARCHAR, sample_id VARCHAR);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue9416 VALUES
|
||||
('197bc9528efbc76a523d796b749a69f6','json','0bf0b46fb9c01829c55e','e4de2878',NULL),
|
||||
('0f62e5fa923495012f3863e7ea05f566','json','d98171d6fe06b3','440ce2bf','9fc93ee404d6bccb69'),
|
||||
('9b15a709814582ecbec00d8397852865','json','24ed1657','c3d1f46c','06c234e260a7484'),
|
||||
('8569d67b0ccbbf316b360be3bb4fe418','json','d98171d6fe06b3','14875a37','3416100f300c7bd'),
|
||||
('d2f02b24d59696079e3d649b403fbb22','json','82e092e750a','e7deeb7f','6d8dded6f044'),
|
||||
('60a2b8898440b2f4531268e27b7d3495','json','f657d34b6','46afa8e7','7bb186ce013b'),
|
||||
('5aa1982136f3991ad5ed537793d40a0f','json','d58e2b351518','a98b2b0c','ac594941b5d9'),
|
||||
('cc70cc91af828c833b5bf20785b91918','json','4953ff4b','8450467c','d1509d0abde0'),
|
||||
('7cf99d6372183aab6a9a22205e1b0e96','json','14b5b262c52400','e7deeb7f','6d8dded6f044'),
|
||||
('3cf6f7ec6609c6456f6587c441310ace','json','0c155a1ba5','e984dd5b','d374014b756d'),
|
||||
('e1223eb2cc51161d32495ff0ad8b34ae','json','f05964c5c4','4f3354c3','10eebe991cf9'),
|
||||
('7b8b64bac7c7dc692d1fe76f6eeff2bb','json','6bd9ce7f1d8','492f260c','314d3e061be7'),
|
||||
('7b8b64bac7c7dc692d1fe76f6eeff2bb','json','249f40c5d97','492f260c','314d3e061be7'),
|
||||
('cd29186ef73b658079d848fca1ebe839','json','6bd9ce7f1d8','492f260c','314d3e061be7'),
|
||||
('d67a74eb29392e06b97161d9f3121705','json','0bf0b46fb9c01829c55e','2d28e9ee','0deb6a6b189d309'),
|
||||
('9dcc686429408e3319161c39b008f705','json','24ed1657','8450467c','d1509d0abde0'),
|
||||
('11788bb5a0477c1bfb31a9f33af80c40','json','4ea4e97b39c4b','4f3354c3','10eebe991cf9'),
|
||||
('59bceab687b4004dbeed6291f07af37d','json','6d00cb7409','4f3354c3','10eebe991cf9'),
|
||||
('76b23210847e653b6060104da0e86d5b','json','24ed1657','22f4528f','7632cf8f4849404'),
|
||||
('2605143ff05ae1ce66b1cc70f80fe53d','json','249f40c5d97','b93c50ce','be70d8b88fff'),
|
||||
('1a1864b5f4ed27acfbbf6e5069348a5a','json','6bd9ce7f1d8','6c082f61','ee109745d498'),
|
||||
('92200c3306e18e53a41550c6306a3ee4','json','8271fea91bc236c','d6f24fd5',NULL),
|
||||
('dd39e08b282cf4a6429bcfefaa2af071','json','249f40c5d97','1396d8b6','3826343264acc9'),
|
||||
('3afcae2318313f112b62536fa160678d','json','24ed1657','5311f290','129c0a0fd3e82a8'),
|
||||
('3afcae2318313f112b62536fa160678d','json','24ed1657','08b8de7c543d','129c0a0fd3e82a8'),
|
||||
('3afcae2318313f112b62536fa160678d','json','24ed1657','ce001fa3a2a4','129c0a0fd3e82a8'),
|
||||
('79acd6669071e95a5b2fe5456216ab32','json','24ed1657','5311f290','129c0a0fd3e82a8'),
|
||||
('79acd6669071e95a5b2fe5456216ab32','json','24ed1657','08b8de7c543d','129c0a0fd3e82a8'),
|
||||
('79acd6669071e95a5b2fe5456216ab32','json','24ed1657','ce001fa3a2a4','129c0a0fd3e82a8'),
|
||||
('d0a7e9d3eda115120021a895a81db8be','json','24ed1657','5311f290','129c0a0fd3e82a8'),
|
||||
('d0a7e9d3eda115120021a895a81db8be','json','24ed1657','08b8de7c543d','129c0a0fd3e82a8'),
|
||||
('d0a7e9d3eda115120021a895a81db8be','json','24ed1657','ce001fa3a2a4','129c0a0fd3e82a8'),
|
||||
('a59a3a4ad8d2ab867c9b830974588645','json','24ed1657','5311f290','129c0a0fd3e82a8'),
|
||||
('a59a3a4ad8d2ab867c9b830974588645','json','24ed1657','08b8de7c543d','129c0a0fd3e82a8'),
|
||||
('a59a3a4ad8d2ab867c9b830974588645','json','24ed1657','ce001fa3a2a4','129c0a0fd3e82a8'),
|
||||
('6193ffd18b0da96e80e2a38baac9a7e4','json','14b5b262c52400','3c03d64c34','1b5cfdd6a5de'),
|
||||
('6193ffd18b0da96e80e2a38baac9a7e4','rprt','1a5cf3833',NULL,'1b5cfdd6a5de'),
|
||||
('ecf1739fed72151784dab88dbe2f2aa9','json','14b5b262c52400','3c03d64c34','1b5cfdd6a5de'),
|
||||
('ecf1739fed72151784dab88dbe2f2aa9','rprt','1a5cf3833',NULL,'1b5cfdd6a5de'),
|
||||
('204cd9b011e2cab64bcdf1b3d668a9ef','json','7d9a79908fcc','8274fbb94a','5a928f187ed19b2'),
|
||||
('c8360bd0e28ea5bbffd66e76886bbccb','json','d6b3921920','a63d8','0e06e1f9f6580fb'),
|
||||
('c8360bd0e28ea5bbffd66e76886bbccb','rprt','d6b3921920',NULL,'0e06e1f9f6580fb'),
|
||||
('c6eb00fb5a023557439a9b898c7cc3ea','json','d6b3921920','a63d8','f891b965f2561d9'),
|
||||
('c6eb00fb5a023557439a9b898c7cc3ea','rprt','d6b3921920',NULL,'f891b965f2561d9'),
|
||||
('f2dacff642ad3f805229d7e976810f1d','rprt','d6b3921920',NULL,'6817ec9d3b7b726'),
|
||||
('8def2cd0450b56c3e0c9bb6da67b842b','rprt','d6b3921920',NULL,'6817ec9d3b7b726'),
|
||||
('6db7ef8b4a9e41bb41971dced546131b','rprt','d6b3921920',NULL,'bc32d9059dde8ba'),
|
||||
('4524efca2bf1aa0565f03a9aaf9771d2','json','14b5b262c52400','cf3b1945e2','5c0157ef5367'),
|
||||
('6f63a84401944c32b9a329af08d6473c','json','8b736466c7adc6','d0acb13cd9','d734a9d755ef6276'),
|
||||
('8ef4bc6ac39585b2ec45218ad1d06464','rprt','67b7fd541ae7e','c117f7db3b','cf94993616ef'),
|
||||
('01899ea72c60bd5e614132c99fffd48e','json','14b5b262c52400','2a50feb98b','eead79cf6ef0'),
|
||||
('b1407bdda20fad91cb9072c08c5c23a8','json','3608008ba4c9','e4840a8e75','139e04ae890beb8'),
|
||||
('2091d4939af33d3911b057ed446367f1','rprt','6522e2c00f5b87d5b','f2b8d4d02d','23de2ff19778'),
|
||||
('81f36975a777a353b0861874e03d0f95','rprt','14b5b262c52400','e05f1a1ec2','acf577df3840'),
|
||||
('5b3961bf4255e83ee1e7e795e14c8119','rprt','b9cbf09f3366297','1109e52066','47afce7dacb5'),
|
||||
('0b53312f91b22db1bf7c18251a199d36','json','14b5b262c52400','c8561fe22f','6e30638eaaf6'),
|
||||
('e277322f26cd477bae52240c46678286','json','14b5b262c52400','d185c22b68','42a062d827c'),
|
||||
('71150d87b4e7852448a524e03817efc4','json','bb87c32c765d1','3e60145162','8e072527a7cf82d'),
|
||||
('1039fc7de3c12dad1e7d3bd9e73827de','json','d6b3921920','65c0a3e2a9','9ff56f55c850390'),
|
||||
('3c67c976516f8a5a1044ad9a8935cf02','rprt','bdc5a7fd6ca','dfc9fd824b','bfbef96674e73829'),
|
||||
('56ab3e25a40913b6e961cff217a83750','json','24ed1657','724e7df1','fc81c8a39465'),
|
||||
('5f726fff8b638d0ac1ba9dcb9a4037be','json','14b5b262c52400','b1bddeb160','1e2b4afd36f'),
|
||||
('4448f84ff7496b6d1a0d311838be238d','json','14b5b262c52400','50a45c4db0','83ef23a7f827'),
|
||||
('216414a29307f00aecfc9e5cba7ac821','json','c05bced980e6381','949ae57ce4','05f77bf546f'),
|
||||
('5327f9ec2dc334bde0222b52de4d65ef','json','67b7fd541ae7e','8aea85ada0','c0048c2b539e'),
|
||||
('d3c9b836ce61a53daf39d813c97a36b9','json','249f40c5d97','35d05d68','db4853c8a41'),
|
||||
('6d4affc7041c65d0f56551f4d4370a7d','rprt','d6b3921920',NULL,'84624aa9753a681'),
|
||||
('caab5b21770a321067fb2052c2eea792','rprt','14b5b262c52400','8b8da80085','d427763bd611'),
|
||||
('eecdf1e7e87c04c56328b0d37fb06349','json','14b5b262c52400','3bfabeb9d9','7c613b2d73cc'),
|
||||
('b533aa0c674433a09cee8555b35b7ca6','json','9c3b3335f959','f9d8c52aa2','d082926c94a8a60'),
|
||||
('6dfe749835d6a895a3a116580dc4217a','rprt','14b5b262c52400','6dd9b2d650','b3d88f29e3e5'),
|
||||
('6150133032c53a35ce28c6308931137d','rprt','b04a2a75f0c4a9','9f3026e2','a1bcb7232a50'),
|
||||
('47e77fd2d027114df5ac9daa17237934','json','b04a2a75f0c4a9','6e07291b','564347d748e0'),
|
||||
('0d66c06fd2a29247b4bc798591f15cbc','rprt','093a316f6c9c0856b','ebcca53e20','4c767b833785b25b072e'),
|
||||
('997371252646aed7ac3fa43da1f69ef2','rprt','d6b3921920','5be2b052','612fc8691ec7852'),
|
||||
('e963d96d34e35ba06cea05ff78e84e41','json','33debfe262d7','114a0c85','f6d1ea3976b0a03'),
|
||||
('f50959f1079cd24b7dcb6370d8e63344','rprt','1a5cf3833',NULL,'a1b77be48d05'),
|
||||
('4e44d4c96d3d26290d13e5f9bc14d8dd','rprt','67b7fd541ae7e','c117f7db3b','18d653ec3c0'),
|
||||
('797c887ce1edab55fefaa7a690065843','rprt','14b5b262c52400','22efccc05e','7a9348e1538f'),
|
||||
('ffbc9337bb6f6c7d43ab32a9398474da','rprt','b04a2a75f0c4a9','6e07291b','564347d748e0'),
|
||||
('3ac840afe9d088e5c490ed4cd48d2269','json','67b7fd541ae7e','ffaa35275c','c58867f82d10'),
|
||||
('72cedda51ecfb6678f4e3a3956066311','json','402423768220bca1f','9a28c664','eed0f9697609'),
|
||||
('92488464899a3b31ea1bc61a2ebc2013','json','14b5b262c52400','1a10cdadd7','ee4cacc7ce10'),
|
||||
('c85e95cfec9f42fff138d498101cd7ea','json','14b5b262c52400','f1b4cf931e','3b4f71a3ddde'),
|
||||
('399edac903f69ac760fa36a8b68cdfb0','rprt','67b7fd541ae7e','a539fb31c3','4c920da298bd'),
|
||||
('a223c0e6017570f5a1039003e767e692','json','67b7fd541ae7e','7bfb6b3721','5ae5c617d126'),
|
||||
('1503860c3c6391385807ab9b6cdd1934','json','67b7fd541ae7e','4936ad40b0','94fbcb7cd167'),
|
||||
('6f269d7f6cf850a9cd0d4d804eef24a0','rprt','14b5b262c52400','943c04e54b','cc79fc503d80'),
|
||||
('732a12aa44489aeef05b614a1e8dbd2d','rprt','14b5b262c52400','a2335b4159','45e7e30aa621'),
|
||||
('b876617f4b7bdb3abc694da31b09d838','rprt','14b5b262c52400','93a91bf863','b824ed7a5f67'),
|
||||
('fd63b4bf7ee546b2c0c55200ae968872','rprt','67b7fd541ae7e','62cd05887b','9c1940a4032a'),
|
||||
('50a00a903778fb65ef92a736bd9fe262','json','67b7fd541ae7e','7e81c8b2f3','00eb98252668113'),
|
||||
('053891bc9d52d48986302c5e13adf276','json','67b7fd541ae7e','a1762f3d79','e06b767a6ed2'),
|
||||
('f537b4d753bb441436ff8d73af423691','json','efdfcef7da0','98c6db64','4c9b34c566ae'),
|
||||
('8dc4f5e5bb2663f09218b369be5bf524','rprt','03b000865c98e','f31af55c63','a02983ae108ced0449cb4'),
|
||||
('d69d899aba162c4f14593f9c6a062bdd','rprt','67b7fd541ae7e','7bfb6b3721','c32aa62b7207'),
|
||||
('88b784ce065a5cf2360e7616c4b3f7f6','json','62769691cd4e','ebdf919e','37e16f2e5319832f'),
|
||||
('cdda71f56ad05dae20b1e22ee19b227b','rprt','67b7fd541ae7e','17d7c8f29a','21c1f8fadde3'),
|
||||
('5e1d22685085f0d85553eb2b7b4155a6','rprt','14b5b262c52400','737542af23','092dcc6fdef7'),
|
||||
('7f387dad4f9bef7c2301977590cec0f2','json','67b7fd541ae7e','09591aea45','ab584388528d'),
|
||||
('a83145a960baebcf1bff9c462f8489e5','json','14b5b262c52400','2ea6e3e6fb','4fe26b0e2203'),
|
||||
('4d7a36c58267592481297676d57c9e84','json','581d813a840d3d6391','54239e1a8e','232d99055474'),
|
||||
('31f0b71e67e64d42079098a53374e094','json','14b5b262c52400','a43ad72889','7d702f310fbe'),
|
||||
('6ddc75b9771136d9a6366aaa5d951f1a','rprt','14b5b262c52400','75263a6f0c','7309f2e8695a'),
|
||||
('4595e59a1225042680842f63736481d4','json','14b5b262c52400','44f5fdb8b1','9c2c14ec6924'),
|
||||
('66c1f24117ee34a1b3d587a22047fad1','rprt','14b5b262c52400','bfe39ca56f','b49aa5fad4d5'),
|
||||
('37027bc152a681b87d5ffb9a37c325a5','rprt','efdfcef7da0','9f1668a8','682ff39acb86'),
|
||||
('c3b46edd87eb14842b6444c001ae6456','json','3608008ba4c9','f650844d13','5326d2a94e28825'),
|
||||
('82beaa8e1c8c482d792f601b37a40b8a','rprt','14b5b262c52400','c86e0093c2','5ae33221b17'),
|
||||
('333aa3a45ab3f01ad95b2a312870aa1e','json','14b5b262c52400','57f7ec0030','8545146eeba5'),
|
||||
('16b64ffcb514bf69c6936eaf4e86889e','rprt','14b5b262c52400','2a50feb98b','64bb80701037'),
|
||||
('01d42ee5515c3b500018e723278e27c1','json','67b7fd541ae7e','958967a48a','97453818ba51'),
|
||||
('2a031d3176c7d4f19c532e5d2e7b411e','rprt','14b5b262c52400','164c3bb214','3389fe2776be'),
|
||||
('8d3b5d415e43df82b6b560effeb6ee80','json','67b7fd541ae7e','9205577d7c','bc96b93082c6'),
|
||||
('339690825234f32fd7da02fd567d5109','rprt','b04a2a75f0c4a9','9f3026e2','a1bcb7232a50'),
|
||||
('13c6d4555db02b653d8f2b5ce06bb143','json','402423768220bca1f','49d58dba','59b0906f7fcb'),
|
||||
('39a39a7e3c48c1b3b262e8653b1a3ec4','rprt','14b5b262c52400','7b34590a85','eec88226d871'),
|
||||
('fdd9d71a087b9048b8ac7dd29186cedf','rprt','315316c7af745a97','8a7c0917d4','743680a0303171bbd'),
|
||||
('f37e684c9ec0d0690a3c6feeaf6b1301','json','14b5b262c52400','0059c84703','8426f8984729'),
|
||||
('3787d0c9ead3866324d7586044747d65','rprt','b9cbf09f3366297','3822b4212e','611f4b0f498e')
|
||||
;
|
||||
|
||||
# dup n_dup n_spcmn idx source project specimen sample_id
|
||||
query IIIIIIII
|
||||
WITH dups AS (
|
||||
SELECT ROW_NUMBER() OVER same_idx AS dup
|
||||
, COUNT(*) OVER same_idx AS n_dup
|
||||
, (DENSE_RANK() OVER asc_spcmn) + (DENSE_RANK() OVER desc_spcmn) - 1 AS n_spcmn
|
||||
, *
|
||||
FROM issue9416
|
||||
WINDOW same_idx AS (
|
||||
PARTITION BY idx
|
||||
ORDER BY source, project, specimen
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
, asc_spcmn AS (
|
||||
PARTITION BY idx
|
||||
ORDER BY specimen ASC NULLS FIRST
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
, desc_spcmn AS (
|
||||
PARTITION BY idx
|
||||
ORDER BY specimen DESC NULLS LAST
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
)
|
||||
SELECT *
|
||||
FROM dups
|
||||
WHERE n_spcmn > 1
|
||||
ORDER BY idx, dup;
|
||||
----
|
||||
1 3 3 3afcae2318313f112b62536fa160678d json 24ed1657 08b8de7c543d 129c0a0fd3e82a8
|
||||
2 3 3 3afcae2318313f112b62536fa160678d json 24ed1657 5311f290 129c0a0fd3e82a8
|
||||
3 3 3 3afcae2318313f112b62536fa160678d json 24ed1657 ce001fa3a2a4 129c0a0fd3e82a8
|
||||
1 2 2 6193ffd18b0da96e80e2a38baac9a7e4 json 14b5b262c52400 3c03d64c34 1b5cfdd6a5de
|
||||
2 2 2 6193ffd18b0da96e80e2a38baac9a7e4 rprt 1a5cf3833 NULL 1b5cfdd6a5de
|
||||
1 3 3 79acd6669071e95a5b2fe5456216ab32 json 24ed1657 08b8de7c543d 129c0a0fd3e82a8
|
||||
2 3 3 79acd6669071e95a5b2fe5456216ab32 json 24ed1657 5311f290 129c0a0fd3e82a8
|
||||
3 3 3 79acd6669071e95a5b2fe5456216ab32 json 24ed1657 ce001fa3a2a4 129c0a0fd3e82a8
|
||||
1 3 3 a59a3a4ad8d2ab867c9b830974588645 json 24ed1657 08b8de7c543d 129c0a0fd3e82a8
|
||||
2 3 3 a59a3a4ad8d2ab867c9b830974588645 json 24ed1657 5311f290 129c0a0fd3e82a8
|
||||
3 3 3 a59a3a4ad8d2ab867c9b830974588645 json 24ed1657 ce001fa3a2a4 129c0a0fd3e82a8
|
||||
1 2 2 c6eb00fb5a023557439a9b898c7cc3ea json d6b3921920 a63d8 f891b965f2561d9
|
||||
2 2 2 c6eb00fb5a023557439a9b898c7cc3ea rprt d6b3921920 NULL f891b965f2561d9
|
||||
1 2 2 c8360bd0e28ea5bbffd66e76886bbccb json d6b3921920 a63d8 0e06e1f9f6580fb
|
||||
2 2 2 c8360bd0e28ea5bbffd66e76886bbccb rprt d6b3921920 NULL 0e06e1f9f6580fb
|
||||
1 3 3 d0a7e9d3eda115120021a895a81db8be json 24ed1657 08b8de7c543d 129c0a0fd3e82a8
|
||||
2 3 3 d0a7e9d3eda115120021a895a81db8be json 24ed1657 5311f290 129c0a0fd3e82a8
|
||||
3 3 3 d0a7e9d3eda115120021a895a81db8be json 24ed1657 ce001fa3a2a4 129c0a0fd3e82a8
|
||||
1 2 2 ecf1739fed72151784dab88dbe2f2aa9 json 14b5b262c52400 3c03d64c34 1b5cfdd6a5de
|
||||
2 2 2 ecf1739fed72151784dab88dbe2f2aa9 rprt 1a5cf3833 NULL 1b5cfdd6a5de
|
||||
172
external/duckdb/test/sql/window/test_empty_frames.test
vendored
Normal file
172
external/duckdb/test/sql/window/test_empty_frames.test
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
# name: test/sql/window/test_empty_frames.test
|
||||
# description: Empty aggregate frames
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1 (id INTEGER, ch CHAR(1)) ;
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (1, 'A');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (2, 'B');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (NULL, 'B');
|
||||
|
||||
#
|
||||
# Original bug report
|
||||
#
|
||||
|
||||
foreach agg count(*) count_star()
|
||||
|
||||
query II
|
||||
SELECT id, ${agg} OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 0
|
||||
2 1
|
||||
NULL 0
|
||||
|
||||
endloop
|
||||
|
||||
#
|
||||
# All zeroes
|
||||
#
|
||||
foreach agg approx_count_distinct count entropy
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 0
|
||||
2 0
|
||||
NULL 0
|
||||
|
||||
endloop
|
||||
|
||||
#
|
||||
# All NULLs
|
||||
#
|
||||
foreach agg any_value arbitrary avg bit_and bit_or bit_xor favg first fsum group_concat histogram kahan_sum kurtosis last listagg mad max mean median min mode product sem skewness stddev stddev_pop stddev_samp sum sumkahan var_pop var_samp variance
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
#
|
||||
# Custom results
|
||||
#
|
||||
|
||||
# Numeric parameter argument
|
||||
foreach agg approx_quantile quantile quantile_cont quantile_disc reservoir_quantile
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id, 0.5) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
# Mixed arguments
|
||||
foreach agg arg_max arg_min argmax argmin max_by min_by
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id, ch) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
foreach agg array_agg list
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 [NULL]
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
# Boolean argument
|
||||
foreach agg bool_and bool_or
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id > 0) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
# Two numeric arguments =>NULL
|
||||
foreach agg corr covar_pop covar_samp regr_avgx regr_avgy regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id, id) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
endloop
|
||||
|
||||
# Two numeric arguments => 0
|
||||
foreach agg regr_count
|
||||
|
||||
query II
|
||||
SELECT id, ${agg}(id, id) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 0
|
||||
2 0
|
||||
NULL 0
|
||||
|
||||
endloop
|
||||
|
||||
query II
|
||||
SELECT id, string_agg(id, ' ') OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
|
||||
query II
|
||||
SELECT id, bitstring_agg(id, 1, 3) OVER (PARTITION BY ch ORDER BY id ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
|
||||
FROM t1
|
||||
ORDER BY 1;
|
||||
----
|
||||
1 NULL
|
||||
2 NULL
|
||||
NULL NULL
|
||||
87
external/duckdb/test/sql/window/test_evil_window.test
vendored
Normal file
87
external/duckdb/test/sql/window/test_evil_window.test
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# name: test/sql/window/test_evil_window.test
|
||||
# description: More evil cases
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# negative lag
|
||||
query II
|
||||
select *
|
||||
from (
|
||||
select lag(i, -1) over () as negative, lead(i, 1) over () as positive
|
||||
from generate_series(0, 10, 1) tbl(i)
|
||||
) w
|
||||
where negative <> positive
|
||||
----
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date)
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15')
|
||||
|
||||
# aggr as input to window
|
||||
query TR
|
||||
SELECT depname, sum(sum(salary)) over (partition by depname order by salary) FROM empsalary group by depname, salary order by depname, salary
|
||||
----
|
||||
develop 4200.000000
|
||||
develop 8700.000000
|
||||
develop 19100.000000
|
||||
develop 25100.000000
|
||||
personnel 3500.000000
|
||||
personnel 7400.000000
|
||||
sales 9600.000000
|
||||
sales 14600.000000
|
||||
|
||||
# expr in window
|
||||
query IR
|
||||
SELECT empno, sum(salary*2) OVER (PARTITION BY depname ORDER BY empno) FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
7 8400.000000
|
||||
8 20400.000000
|
||||
9 29400.000000
|
||||
10 39800.000000
|
||||
11 50200.000000
|
||||
2 7800.000000
|
||||
5 14800.000000
|
||||
1 10000.000000
|
||||
3 19600.000000
|
||||
4 29200.000000
|
||||
|
||||
# expr ontop of window
|
||||
query IR
|
||||
SELECT empno, 2*sum(salary) OVER (PARTITION BY depname ORDER BY empno) FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
7 8400.000000
|
||||
8 20400.000000
|
||||
9 29400.000000
|
||||
10 39800.000000
|
||||
11 50200.000000
|
||||
2 7800.000000
|
||||
5 14800.000000
|
||||
1 10000.000000
|
||||
3 19600.000000
|
||||
4 29200.000000
|
||||
|
||||
# tpcds-derived window
|
||||
query TR
|
||||
SELECT depname, sum(salary)*100.0000/sum(sum(salary)) OVER (PARTITION BY depname ORDER BY salary) AS revenueratio FROM empsalary GROUP BY depname, salary ORDER BY depname, revenueratio
|
||||
----
|
||||
develop 23.904382
|
||||
develop 51.724138
|
||||
develop 54.450262
|
||||
develop 100.000000
|
||||
personnel 52.702703
|
||||
personnel 100.000000
|
||||
sales 34.246575
|
||||
sales 100.000000
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empty_unsorted(c0 VARCHAR);
|
||||
|
||||
statement ok
|
||||
SELECT *
|
||||
FROM empty_unsorted
|
||||
WHERE(NOT(false = ANY([])))
|
||||
ORDER BY(~((SUM(true) OVER() - SUM(true) OVER())::INT)) ASC;
|
||||
432
external/duckdb/test/sql/window/test_fill.test
vendored
Normal file
432
external/duckdb/test/sql/window/test_fill.test
vendored
Normal file
@@ -0,0 +1,432 @@
|
||||
# name: test/sql/window/test_fill.test
|
||||
# description: Test Fill function
|
||||
# group: [window]
|
||||
|
||||
#
|
||||
# Error checks
|
||||
#
|
||||
|
||||
# Only one ordering allowed
|
||||
statement error
|
||||
select fill(i) over (order by i, 10-i) from range(3) tbl(i);
|
||||
----
|
||||
FILL functions must have only one ORDER BY expression
|
||||
|
||||
# Streaming not supported because the interpolation values might be too far away.
|
||||
statement error
|
||||
select fill(i) over () from range(3) tbl(i);
|
||||
----
|
||||
FILL functions must have only one ORDER BY expression
|
||||
|
||||
# Argument must be numeric
|
||||
statement error
|
||||
select fill(i::VARCHAR) over (order by i) from range(3) tbl(i);
|
||||
----
|
||||
FILL argument must support subtraction
|
||||
|
||||
# Ordering must be numeric
|
||||
statement error
|
||||
select fill(i) over (order by i::VARCHAR) from range(3) tbl(i);
|
||||
----
|
||||
FILL ordering must support subtraction
|
||||
|
||||
#
|
||||
# Simple interpolation coverage tests
|
||||
#
|
||||
|
||||
foreach ordertype tinyint smallint integer bigint hugeint float double utinyint usmallint uinteger ubigint uhugeint
|
||||
|
||||
foreach filltype tinyint smallint integer bigint hugeint float double utinyint usmallint uinteger ubigint uhugeint
|
||||
|
||||
loop nulled 0 3
|
||||
|
||||
# Between, before and after
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i = ${nulled}, NULL, i)::${filltype}) over(order by i::${ordertype}) as f
|
||||
from range(3) tbl(i)
|
||||
qualify i is distinct from f
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
# Single values
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i > 0, NULL, i)::${filltype}) over(order by i::${ordertype}) as f
|
||||
from range(3) tbl(i)
|
||||
qualify f is distinct from 0
|
||||
----
|
||||
|
||||
# No values in partition
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i < 4, NULL, i)::${filltype}) over(partition by i // 2 order by i::${ordertype}) f
|
||||
from range(8) tbl(i)
|
||||
order by i
|
||||
----
|
||||
0 NULL
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 NULL
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
|
||||
# Outside valid sort values
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i = 2, NULL, i)::${filltype}) over(order by if(i < 4, NULL, i)::${ordertype}) f
|
||||
from range(8) tbl(i)
|
||||
qualify i is distinct from f
|
||||
order by i
|
||||
----
|
||||
2 NULL
|
||||
|
||||
foreach sense asc desc
|
||||
|
||||
foreach nulls first last
|
||||
|
||||
# NULL sort key coverage
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(i::${filltype}) over(order by i::${ordertype} ${sense} nulls ${nulls}) f
|
||||
from (
|
||||
from range(3) r(i)
|
||||
union all
|
||||
select NULL as i
|
||||
) tbl(i)
|
||||
qualify i is distinct from f
|
||||
order by i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
foreach ordertype smallint integer bigint hugeint float double usmallint uinteger ubigint uhugeint
|
||||
|
||||
foreach filltype smallint integer bigint hugeint float double usmallint uinteger ubigint uhugeint
|
||||
|
||||
# Previous in another chunk
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i = 2048, NULL, i)::${filltype}) over(order by i::${ordertype}) f
|
||||
from range(2060) tbl(i)
|
||||
qualify i <> f
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
#
|
||||
# Temporal coverage
|
||||
#
|
||||
|
||||
foreach ordertype date timestamp timestamptz
|
||||
|
||||
foreach filltype date timestamp timestamptz
|
||||
|
||||
loop nulled 1 4
|
||||
|
||||
# Before, Between and After values
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(day(i) = ${nulled}, NULL, i)::${filltype}) over(order by i::${ordertype}) f
|
||||
from range('2025-01-01'::DATE, '2025-01-04'::DATE, INTERVAL 1 DAY) tbl(i)
|
||||
qualify f <> i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
foreach sense asc desc
|
||||
|
||||
foreach nulls first last
|
||||
|
||||
# NULL sort key coverage
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(i::${filltype}) over(order by i::${ordertype} ${sense} nulls ${nulls}) f
|
||||
from (
|
||||
from range('2025-01-01'::DATE, '2025-01-04'::DATE, INTERVAL 1 DAY) r(i)
|
||||
union all
|
||||
select NULL as i
|
||||
) tbl(i)
|
||||
qualify i is distinct from f
|
||||
order by i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
# Single values
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(day(i) > 1, NULL, i)::${filltype}) over(order by i::${ordertype}) f
|
||||
from range('2025-01-01'::DATE, '2025-01-04'::DATE, INTERVAL 1 DAY) tbl(i)
|
||||
qualify f <> '2025-01-01'::DATE
|
||||
----
|
||||
|
||||
# No values in partition
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(day(i) < 5, NULL, i)::${filltype}) over(partition by (day(i) - 1) // 2 order by i::${ordertype}) f
|
||||
from range('2025-01-01'::DATE, '2025-01-09'::DATE, INTERVAL 1 DAY) tbl(i)
|
||||
qualify f is NULL
|
||||
order by i
|
||||
----
|
||||
2025-01-01 00:00:00 NULL
|
||||
2025-01-02 00:00:00 NULL
|
||||
2025-01-03 00:00:00 NULL
|
||||
2025-01-04 00:00:00 NULL
|
||||
|
||||
# Outside valid sort values
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(day(i) = 3, NULL, i)::${filltype}) over(order by if(day(i) < 5, NULL, i)::${ordertype}) f
|
||||
from range('2025-01-01'::DATE, '2025-01-09'::DATE, INTERVAL 1 DAY) tbl(i)
|
||||
qualify i is distinct from f
|
||||
order by i
|
||||
----
|
||||
2025-01-03 00:00:00 NULL
|
||||
|
||||
# Previous in another chunk
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i = '2015-01-01'::DATE + 2048, NULL, i)::${filltype}) over(order by i::${ordertype}) f
|
||||
from range('2025-01-01'::DATE, '2020-08-22'::DATE, INTERVAL 1 DAY) tbl(i)
|
||||
qualify i <> f
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
# Time
|
||||
|
||||
loop nulled 1 4
|
||||
|
||||
# Before, Between and After values
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(if(minute(i) = ${nulled}, NULL, i)::TIME) over(order by i::TIME) f
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:03'::TIMESTAMP, INTERVAL 1 MINUTE) tbl(i)
|
||||
qualify f <> t
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
foreach sense asc desc
|
||||
|
||||
foreach nulls first last
|
||||
|
||||
# NULL sort key coverage
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(t) over(order by t ${sense} nulls ${nulls}) f
|
||||
from (
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:03'::TIMESTAMP, INTERVAL 1 MINUTE) r(i)
|
||||
union all
|
||||
select NULL as i
|
||||
) tbl(i)
|
||||
qualify t is distinct from f
|
||||
order by t
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
# Single values
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(if(minute(i) > 0, NULL, i)::TIME) over(order by i::TIME) f
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:03'::TIMESTAMP, INTERVAL 1 MINUTE) tbl(i)
|
||||
qualify f <> '00:00:00'::TIME
|
||||
----
|
||||
|
||||
# No values in partition
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(if(minute(i) < 4, NULL, i)::TIME) over(partition by minute(i) // 2 order by i::TIME) f
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:09'::TIMESTAMP, INTERVAL 1 MINUTE) tbl(i)
|
||||
qualify f is not NULL
|
||||
order by t
|
||||
----
|
||||
00:04:00 00:04:00
|
||||
00:05:00 00:05:00
|
||||
00:06:00 00:06:00
|
||||
00:07:00 00:07:00
|
||||
00:08:00 00:08:00
|
||||
|
||||
# Outside valid sort values
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(if(minute(i) = 3, NULL, i)::TIME) over(order by if(minute(i) < 4, NULL, i)::TIME) f
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:09'::TIMESTAMP, INTERVAL 1 MINUTE) tbl(i)
|
||||
qualify t is distinct from f
|
||||
order by t
|
||||
----
|
||||
00:03:00 NULL
|
||||
|
||||
# Previous in another chunk
|
||||
query II
|
||||
select
|
||||
i::TIME t,
|
||||
fill(if(i = '2015-01-01'::TIMESTAMP + INTERVAL 2048 SECOND, NULL, i)::TIME) over(order by i::TIME) f
|
||||
from range('2025-01-01'::TIMESTAMP, '2025-01-01 00:34:20'::TIMESTAMP, INTERVAL 1 SECOND) tbl(i)
|
||||
qualify t <> f
|
||||
----
|
||||
|
||||
#
|
||||
# Extrapolation failures
|
||||
#
|
||||
|
||||
# Signed
|
||||
query II
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
if(i = -129, NULL, i)::TINYINT as missing
|
||||
from range(-129, -120) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
fill(missing) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from i
|
||||
----
|
||||
-129 NULL
|
||||
|
||||
query II
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
if(i = 128, NULL, i)::TINYINT as missing
|
||||
from range(120, 129) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
fill(missing) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from i
|
||||
----
|
||||
128 NULL
|
||||
|
||||
# Unsigned
|
||||
query II
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
if(i = -1, NULL, i)::UTINYINT as missing
|
||||
from range(-1, 10) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
fill(missing) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from i
|
||||
----
|
||||
-1 NULL
|
||||
|
||||
query II
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
if(i = 256, NULL, i)::UTINYINT as missing
|
||||
from range(250, 257) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
fill(missing) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from i
|
||||
----
|
||||
256 NULL
|
||||
|
||||
#
|
||||
# Unusable values
|
||||
#
|
||||
# If we use an unsuable value, the interpolation will produce strange values
|
||||
|
||||
# Infinity/NaN
|
||||
|
||||
foreach ordertype float double
|
||||
|
||||
foreach unusable 'infinity' '-infinity' 'NaN'
|
||||
|
||||
loop nullable 0 5
|
||||
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(i = ${nullable}, NULL, i)) over(order by i) f
|
||||
from (
|
||||
from range(5) r(i)
|
||||
union all
|
||||
select ${unusable}::${ordertype} as i
|
||||
) tbl(i)
|
||||
qualify i is distinct from f
|
||||
order by i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
# Temporal infinities
|
||||
|
||||
foreach ordertype date timestamp
|
||||
|
||||
foreach filltype date timestamp
|
||||
|
||||
foreach unusable 'infinity' '-infinity'
|
||||
|
||||
loop nulled 1 4
|
||||
|
||||
query II
|
||||
select
|
||||
i,
|
||||
fill(if(day(i) = ${nulled}, NULL, i)::${filltype}) over(order by i::${ordertype}) f
|
||||
from (
|
||||
from range('2025-01-01'::DATE, '2025-01-05'::DATE, INTERVAL 1 DAY) r(i)
|
||||
union all
|
||||
select ${unusable}::${ordertype} as i
|
||||
) tbl(i)
|
||||
qualify f is NULL
|
||||
order by i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
263
external/duckdb/test/sql/window/test_fill_orderby.test
vendored
Normal file
263
external/duckdb/test/sql/window/test_fill_orderby.test
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
# name: test/sql/window/test_fill_orderby.test
|
||||
# description: Test Fill function with secondary orderings
|
||||
# group: [window]
|
||||
|
||||
#
|
||||
# Error checks
|
||||
#
|
||||
|
||||
# Only one ordering allowed
|
||||
statement error
|
||||
select fill(i order by 10-i, i * i) over (order by i) from range(3) tbl(i);
|
||||
----
|
||||
FILL functions must have only one ORDER BY expression
|
||||
|
||||
# Argument must be numeric
|
||||
statement error
|
||||
select fill(i::VARCHAR order by i) over (order by i) from range(3) tbl(i);
|
||||
----
|
||||
FILL argument must support subtraction
|
||||
|
||||
# Ordering must be numeric
|
||||
statement error
|
||||
select fill(i order by i::VARCHAR) over (order by i) from range(3) tbl(i);
|
||||
----
|
||||
FILL ordering must support subtraction
|
||||
|
||||
#
|
||||
# Simple interpolation coverage tests
|
||||
#
|
||||
|
||||
loop nulled 0 5
|
||||
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
i * 3 % 5 as permuted,
|
||||
if(permuted = ${nulled}, NULL, permuted) as missing
|
||||
from range(5) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted) over (order by i) as filled
|
||||
from source
|
||||
qualify filled <> permuted
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
# Single values
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
i * 3 % 5 as permuted,
|
||||
if(permuted > 0, NULL, permuted) as missing
|
||||
from range(5) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted) over (order by i) as filled
|
||||
from source
|
||||
qualify filled <> permuted
|
||||
----
|
||||
1 3 0
|
||||
2 1 0
|
||||
3 4 0
|
||||
4 2 0
|
||||
|
||||
# No values in partition
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
i * 5 % 11 as permuted,
|
||||
if(permuted < 6, NULL, permuted) as missing
|
||||
from range(11) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted) over (partition by permuted // 5 order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
order by i
|
||||
----
|
||||
0 0 NULL
|
||||
3 4 NULL
|
||||
5 3 NULL
|
||||
7 2 NULL
|
||||
9 1 NULL
|
||||
|
||||
# Outside valid sort values
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
i * 5 % 11 as permuted,
|
||||
if(permuted = 2, NULL, permuted) as missing,
|
||||
if(permuted < 4, NULL, permuted) as unsorted,
|
||||
from range(11) tbl(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by unsorted) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
order by i
|
||||
----
|
||||
7 2 NULL
|
||||
|
||||
# NULL sort key coverage
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
(i + 1) * 3 % 5 as permuted,
|
||||
if(permuted = 0, NULL, permuted) as missing
|
||||
from (
|
||||
from range(5) tbl(i)
|
||||
union all
|
||||
select NULL::INTEGER as i
|
||||
) t(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted asc nulls first) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
----
|
||||
|
||||
query III
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
(i + 1) * 3 % 5 as permuted,
|
||||
if(permuted = 4, NULL, permuted) as missing
|
||||
from (
|
||||
from range(5) tbl(i)
|
||||
union all
|
||||
select NULL::INTEGER as i
|
||||
) t(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted asc nulls last) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
----
|
||||
|
||||
query III
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted asc nulls last) over (order by i) as filled
|
||||
from (values
|
||||
(0, 1, NULL),
|
||||
(1, NULL, 0)
|
||||
) source(i, missing, permuted)
|
||||
order by i
|
||||
----
|
||||
0 NULL 1
|
||||
1 0 NULL
|
||||
|
||||
query III
|
||||
select
|
||||
i,
|
||||
permuted,
|
||||
fill(missing order by permuted asc nulls first) over (order by i) as filled
|
||||
from (values
|
||||
(0, NULL, 2),
|
||||
(1, 0, NULL),
|
||||
(2, 1, 1),
|
||||
) source(i, missing, permuted)
|
||||
order by i
|
||||
----
|
||||
0 2 1
|
||||
1 NULL 0
|
||||
2 1 1
|
||||
|
||||
#
|
||||
# Unusable values
|
||||
#
|
||||
# If we use an unsuable value, the interpolation will produce strange values
|
||||
|
||||
# Infinity/NaN
|
||||
|
||||
foreach ordertype float double
|
||||
|
||||
foreach unusable 'infinity' '-infinity' 'NaN'
|
||||
|
||||
loop nullable 0 5
|
||||
|
||||
query II
|
||||
with source as (
|
||||
select
|
||||
i,
|
||||
(i + 1) * 3 % 5 as permuted,
|
||||
if(permuted = ${nullable}, NULL, permuted) as missing
|
||||
from (
|
||||
select range::${ordertype} as i from range(5)
|
||||
union all
|
||||
select ${unusable}::${ordertype} as i
|
||||
) t(i)
|
||||
)
|
||||
select
|
||||
i,
|
||||
fill(missing order by permuted) over (order by i) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
order by i
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
# Temporal infinities
|
||||
|
||||
foreach ordertype date timestamp
|
||||
|
||||
foreach unusable 'infinity' '-infinity'
|
||||
|
||||
loop nullable 0 5
|
||||
|
||||
query II
|
||||
with source as (
|
||||
(
|
||||
select
|
||||
('2025-01-01'::DATE + INTERVAL (i) DAY)::${ordertype} as t,
|
||||
('2025-01-01'::DATE + INTERVAL ((i + 1) * 3 % 5) DAY)::${ordertype} as permuted,
|
||||
if(i = ${nullable}, NULL, permuted) as missing
|
||||
from range(5) tbl(i)
|
||||
)
|
||||
union all
|
||||
(
|
||||
select
|
||||
${unusable}::${ordertype} as t,
|
||||
t as permuted,
|
||||
permuted as missing
|
||||
)
|
||||
)
|
||||
select
|
||||
t,
|
||||
fill(missing order by permuted) over (order by t) as filled
|
||||
from source
|
||||
qualify filled is distinct from permuted
|
||||
order by t
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
endloop
|
||||
|
||||
354
external/duckdb/test/sql/window/test_ignore_nulls.test
vendored
Normal file
354
external/duckdb/test/sql/window/test_ignore_nulls.test
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
# name: test/sql/window/test_ignore_nulls.test
|
||||
# description: Test IGNORE NULLS window syntax
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Issue #2549
|
||||
statement ok
|
||||
CREATE TABLE issue2549 AS SELECT * FROM (VALUES
|
||||
(0, 1, 614),
|
||||
(1, 1, null),
|
||||
(2, 1, null),
|
||||
(3, 1, 639),
|
||||
(4, 1, 2027)
|
||||
) tbl(id, user_id, order_id);
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAST_VALUE (order_id IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL 614
|
||||
2 1 NULL 614
|
||||
3 1 639 614
|
||||
4 1 2027 639
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
FIRST_VALUE (order_id IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 614
|
||||
1 1 NULL 614
|
||||
2 1 NULL 639
|
||||
3 1 639 639
|
||||
4 1 2027 639
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
NTH_VALUE (order_id, 2 IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL NULL
|
||||
2 1 NULL NULL
|
||||
3 1 639 NULL
|
||||
4 1 2027 639
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LEAD(order_id, 1, -1 IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 639
|
||||
1 1 NULL 639
|
||||
2 1 NULL 639
|
||||
3 1 639 2027
|
||||
4 1 2027 -1
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAG(order_id, 1, -1 IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 -1
|
||||
1 1 NULL 614
|
||||
2 1 NULL 614
|
||||
3 1 639 614
|
||||
4 1 2027 639
|
||||
|
||||
# Zero LAG is always identity
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAG(order_id, 0, -1 IGNORE NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 614
|
||||
1 1 NULL NULL
|
||||
2 1 NULL NULL
|
||||
3 1 639 639
|
||||
4 1 2027 2027
|
||||
|
||||
#
|
||||
# RESPECT NULLS should be the default
|
||||
#
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAST_VALUE (order_id RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL 614
|
||||
2 1 NULL NULL
|
||||
3 1 639 NULL
|
||||
4 1 2027 639
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
FIRST_VALUE (order_id RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL 614
|
||||
2 1 NULL 614
|
||||
3 1 639 614
|
||||
4 1 2027 614
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
NTH_VALUE (order_id, 2 RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL NULL
|
||||
2 1 NULL NULL
|
||||
3 1 639 NULL
|
||||
4 1 2027 NULL
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LEAD(order_id, 1, -1 RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 NULL
|
||||
1 1 NULL NULL
|
||||
2 1 NULL 639
|
||||
3 1 639 2027
|
||||
4 1 2027 -1
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAG(order_id, 1, -1 RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 -1
|
||||
1 1 NULL 614
|
||||
2 1 NULL NULL
|
||||
3 1 639 NULL
|
||||
4 1 2027 639
|
||||
|
||||
# Zero LAG is always identity
|
||||
query IIII
|
||||
SELECT
|
||||
id,
|
||||
user_id,
|
||||
order_id,
|
||||
LAG(order_id, 0, -1 RESPECT NULLS) over (
|
||||
PARTITION BY user_id
|
||||
ORDER BY id
|
||||
) AS last_order_id
|
||||
FROM issue2549
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 1 614 614
|
||||
1 1 NULL NULL
|
||||
2 1 NULL NULL
|
||||
3 1 639 639
|
||||
4 1 2027 2027
|
||||
|
||||
# Edge cases for FIRST/LAST/NTH_VALUE
|
||||
statement ok
|
||||
CREATE TABLE IF NOT EXISTS issue6635(index INTEGER, data INTEGER);
|
||||
|
||||
statement ok
|
||||
insert into issue6635 values
|
||||
(1,1),
|
||||
(2,2),
|
||||
(3,NULL),
|
||||
(4,NULL),
|
||||
(5,5),
|
||||
(6,NULL),
|
||||
(7,NULL)
|
||||
;
|
||||
|
||||
query IIIII
|
||||
SELECT *,
|
||||
first(data IGNORE NULLS) OVER w,
|
||||
last(data IGNORE NULLS) OVER w,
|
||||
nth_value(data, 1 IGNORE NULLS) OVER w
|
||||
FROM issue6635
|
||||
WINDOW w AS (
|
||||
ORDER BY index
|
||||
ROWS BETWEEN 1 FOLLOWING
|
||||
AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
;
|
||||
----
|
||||
1 1 2 5 2
|
||||
2 2 5 5 5
|
||||
3 NULL 5 5 5
|
||||
4 NULL 5 5 5
|
||||
5 5 NULL NULL NULL
|
||||
6 NULL NULL NULL NULL
|
||||
7 NULL NULL NULL NULL
|
||||
|
||||
# Multiple blocks for ignore nulls
|
||||
query IIII
|
||||
WITH gen AS (
|
||||
SELECT *,
|
||||
((id * 1327) % 9973) / 10000.0 AS rnd
|
||||
FROM generate_series(1, 10000) tbl(id)
|
||||
),
|
||||
lvl AS (
|
||||
SELECT id,
|
||||
rnd,
|
||||
CASE
|
||||
WHEN rnd <= 0.1 THEN 'shallow'
|
||||
WHEN rnd >= 0.9 THEN 'high'
|
||||
END AS water_level
|
||||
FROM gen
|
||||
)
|
||||
SELECT *,
|
||||
LAST_VALUE(water_level IGNORE NULLS) OVER (
|
||||
ORDER BY id
|
||||
) AS grade
|
||||
FROM lvl
|
||||
ORDER BY id
|
||||
----
|
||||
40000 values hashing to c302c8b0f3c10c1e5cc7211c4af7a8d6
|
||||
|
||||
# Independent INGORE/RESPECT NULLS with shared input.
|
||||
query III
|
||||
SELECT
|
||||
v,
|
||||
lead(v) OVER (ORDER BY id),
|
||||
lead(v IGNORE NULLS) OVER (ORDER BY id)
|
||||
FROM (VALUES
|
||||
(1, 1),
|
||||
(2, NULL),
|
||||
(3, 2),
|
||||
(4, NULL),
|
||||
(5, 3),
|
||||
(6, NULL)
|
||||
) tbl(id, v);
|
||||
----
|
||||
1 NULL 2
|
||||
NULL 2 2
|
||||
2 NULL 3
|
||||
NULL 3 3
|
||||
3 NULL NULL
|
||||
NULL NULL NULL
|
||||
|
||||
#
|
||||
# Unsupported
|
||||
#
|
||||
|
||||
foreach modifier IGNORE RESPECT
|
||||
|
||||
# Regular function
|
||||
statement error
|
||||
SELECT ABS(x ${modifier} NULLS) FROM range(10) tbl(x)
|
||||
----
|
||||
Parser Error: RESPECT/IGNORE NULLS is not supported for non-window functions
|
||||
|
||||
# Aggregate function
|
||||
statement error
|
||||
SELECT SUM(x ${modifier} NULLS)
|
||||
FROM range(10) tbl(x)
|
||||
----
|
||||
Parser Error: RESPECT/IGNORE NULLS is not supported for non-window functions
|
||||
|
||||
# Windowed aggregate
|
||||
statement error
|
||||
SELECT SUM(x ${modifier} NULLS) OVER (PARTITION BY (x / 3) ORDER BY x % 3)
|
||||
FROM range(10) tbl(x)
|
||||
----
|
||||
Parser Error: RESPECT/IGNORE NULLS is not supported for windowed aggregates
|
||||
|
||||
endloop
|
||||
133
external/duckdb/test/sql/window/test_invalid_window.test
vendored
Normal file
133
external/duckdb/test/sql/window/test_invalid_window.test
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# name: test/sql/window/test_invalid_window.test
|
||||
# description: Illegal window function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date)
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15')
|
||||
|
||||
# GROUP BY window function is not allowed
|
||||
statement error
|
||||
SELECT depname, min(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m1 FROM empsalary GROUP BY m1 ORDER BY depname, empno
|
||||
----
|
||||
|
||||
statement error
|
||||
select row_number() over (range between unbounded following and unbounded preceding);
|
||||
----
|
||||
|
||||
statement error
|
||||
select row_number() over (range between unbounded preceding and unbounded preceding);
|
||||
----
|
||||
|
||||
# ORDER BY is now implemented for window functions!
|
||||
query I
|
||||
select LIST(salary ORDER BY enroll_date, salary) OVER (PARTITION BY depname) FROM empsalary
|
||||
ORDER BY ALL DESC
|
||||
----
|
||||
[6000, 5200, 5200, 4200, 4500]
|
||||
[6000, 5200, 5200, 4200, 4500]
|
||||
[6000, 5200, 5200, 4200, 4500]
|
||||
[6000, 5200, 5200, 4200, 4500]
|
||||
[6000, 5200, 5200, 4200, 4500]
|
||||
[5000, 4800, 4800]
|
||||
[5000, 4800, 4800]
|
||||
[5000, 4800, 4800]
|
||||
[3900, 3500]
|
||||
[3900, 3500]
|
||||
|
||||
# GROUPS frame spec is now implemented for window functions!
|
||||
query I
|
||||
SELECT sum(i) OVER (ORDER BY i GROUPS 1 PRECEDING)
|
||||
FROM generate_series(1,10) AS _(i)
|
||||
ORDER BY i
|
||||
----
|
||||
1
|
||||
3
|
||||
5
|
||||
7
|
||||
9
|
||||
11
|
||||
13
|
||||
15
|
||||
17
|
||||
19
|
||||
|
||||
# Invalid window names
|
||||
foreach invalid PARTITION RANGE ROWS GROUPS
|
||||
|
||||
statement error
|
||||
SELECT array_agg(i) OVER (${invalid} ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
FROM generate_series(1,5) AS _(i)
|
||||
WINDOW ${invalid} AS (ORDER BY i);
|
||||
----
|
||||
syntax error at or near
|
||||
|
||||
endloop
|
||||
|
||||
# Framed non-aggregate functions can't handle EXCLUDE
|
||||
foreach func lead lag ntile
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
i,
|
||||
${func}(i ORDER BY i // 2, i) OVER (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
EXCLUDE TIES
|
||||
) AS f,
|
||||
FROM range(10) tbl(i)
|
||||
ORDER BY i;
|
||||
----
|
||||
EXCLUDE is not supported for the window function
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
i,
|
||||
lead(i ORDER BY i // 2, i) OVER w AS f,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
EXCLUDE TIES
|
||||
)
|
||||
ORDER BY i;
|
||||
----
|
||||
EXCLUDE is not supported for the window function
|
||||
|
||||
endloop
|
||||
|
||||
foreach func row_number rank cume_dist
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
i,
|
||||
${func}(ORDER BY i // 2, i) OVER (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
EXCLUDE TIES
|
||||
) AS f,
|
||||
FROM range(10) tbl(i)
|
||||
ORDER BY i;
|
||||
----
|
||||
EXCLUDE is not supported for the window function
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
i,
|
||||
${func}(ORDER BY i // 2, i) OVER w AS f,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
EXCLUDE TIES
|
||||
)
|
||||
ORDER BY i;
|
||||
----
|
||||
EXCLUDE is not supported for the window function
|
||||
|
||||
endloop
|
||||
137
external/duckdb/test/sql/window/test_lead_lag.test
vendored
Normal file
137
external/duckdb/test/sql/window/test_lead_lag.test
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
# name: test/sql/window/test_lead_lag.test
|
||||
# description: Test Lead/Lag function
|
||||
# group: [window]
|
||||
|
||||
query II
|
||||
select c1, lead(c1, 2) over (order by c0 rows between 2 preceding and 4 preceding) as b
|
||||
from (values
|
||||
(1, 2),
|
||||
(2, 3),
|
||||
(3, 4),
|
||||
(4, 5)
|
||||
) a(c0, c1);
|
||||
----
|
||||
2 4
|
||||
3 5
|
||||
4 NULL
|
||||
5 NULL
|
||||
|
||||
# Lag > 2 with explicit constant default
|
||||
statement ok
|
||||
create table win(id int, v int, t int, f float, s varchar);
|
||||
|
||||
statement ok
|
||||
insert into win values
|
||||
(1, 1, 2, 0.54, 'h'),
|
||||
(1, 1, 1, 0.21, 'e'),
|
||||
(1, 2, 3, 0.001, 'l'),
|
||||
(2, 10, 4, 0.04, 'l'),
|
||||
(2, 11, -1, 10.45, 'o'),
|
||||
(3, -1, 0, 13.32, ','),
|
||||
(3, 5, -2, 9.87, 'wor'),
|
||||
(3, null, 10, 6.56, 'ld');
|
||||
|
||||
query IIII
|
||||
select id, v, t, lag(v, 2, NULL) over (partition by id order by t asc)
|
||||
from win
|
||||
order by id, t
|
||||
----
|
||||
1 1 1 NULL
|
||||
1 1 2 NULL
|
||||
1 2 3 1
|
||||
2 11 -1 NULL
|
||||
2 10 4 NULL
|
||||
3 5 -2 NULL
|
||||
3 -1 0 NULL
|
||||
3 NULL 10 5
|
||||
|
||||
# Shifted lead optimisation with hash collisions
|
||||
statement ok
|
||||
CREATE TABLE issue14398 (date DATE, "group" INT, count INT, status STRING);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue14398 VALUES
|
||||
('2024-01-01', 1, 1000, 'ordered'),
|
||||
('2024-02-01', 1, 1000, 'dispatched'),
|
||||
('2024-03-01', 1, 1000, 'dispatched'),
|
||||
('2024-01-01', 2, 2000, 'ordered'),
|
||||
('2024-02-01', 2, 2000, 'ordered'),
|
||||
('2024-03-01', 2, 2000, 'ordered'),
|
||||
('2024-01-01', 3, 3000, 'ordered'),
|
||||
('2024-02-01', 3, 3000, 'ordered'),
|
||||
('2024-03-01', 3, 3000, 'late'),
|
||||
('2024-01-01', 4, 4000, 'ordered'),
|
||||
('2024-02-01', 4, 4000, 'ordered'),
|
||||
('2024-03-01', 4, 4000, 'ordered'),
|
||||
('2024-01-01', 5, 5000, 'ordered'),
|
||||
('2024-02-01', 5, 5000, 'late'),
|
||||
('2024-03-01', 5, 5000, 'ordered'),
|
||||
('2024-01-01', 6, 1000, 'dispatched'),
|
||||
('2024-02-01', 6, 1000, 'dispatched'),
|
||||
('2024-03-01', 6, 1000, 'dispatched'),
|
||||
('2024-01-01', 7, 1000, 'late'),
|
||||
('2024-02-01', 7, 1000, 'dispatched'),
|
||||
('2024-03-01', 7, 1000, 'dispatched');
|
||||
|
||||
query IIIIII
|
||||
SELECT
|
||||
"t0"."date",
|
||||
"t0"."group",
|
||||
"t0"."count",
|
||||
"t0"."status",
|
||||
LEAD("t0"."date", 2) OVER (PARTITION BY "t0"."group" ORDER BY "t0"."date" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "end_date",
|
||||
LEAD("t0"."status", 2) OVER (PARTITION BY "t0"."group" ORDER BY "t0"."date" ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS "end_status"
|
||||
FROM "issue14398" AS "t0"
|
||||
ORDER BY 2, 1
|
||||
----
|
||||
2024-01-01 1 1000 ordered 2024-03-01 dispatched
|
||||
2024-02-01 1 1000 dispatched NULL NULL
|
||||
2024-03-01 1 1000 dispatched NULL NULL
|
||||
2024-01-01 2 2000 ordered 2024-03-01 ordered
|
||||
2024-02-01 2 2000 ordered NULL NULL
|
||||
2024-03-01 2 2000 ordered NULL NULL
|
||||
2024-01-01 3 3000 ordered 2024-03-01 late
|
||||
2024-02-01 3 3000 ordered NULL NULL
|
||||
2024-03-01 3 3000 late NULL NULL
|
||||
2024-01-01 4 4000 ordered 2024-03-01 ordered
|
||||
2024-02-01 4 4000 ordered NULL NULL
|
||||
2024-03-01 4 4000 ordered NULL NULL
|
||||
2024-01-01 5 5000 ordered 2024-03-01 ordered
|
||||
2024-02-01 5 5000 late NULL NULL
|
||||
2024-03-01 5 5000 ordered NULL NULL
|
||||
2024-01-01 6 1000 dispatched 2024-03-01 dispatched
|
||||
2024-02-01 6 1000 dispatched NULL NULL
|
||||
2024-03-01 6 1000 dispatched NULL NULL
|
||||
2024-01-01 7 1000 late 2024-03-01 dispatched
|
||||
2024-02-01 7 1000 dispatched NULL NULL
|
||||
2024-03-01 7 1000 dispatched NULL NULL
|
||||
|
||||
# test lag and lead when offset is null
|
||||
statement ok
|
||||
CREATE TABLE issue17266(c1 INT, c2 SMALLINT, c3 BITSTRING);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue17266 VALUES
|
||||
(0, null, null),
|
||||
(1, 32767, '101'),
|
||||
(2, -32767, '101'),
|
||||
(3, 0, '000'),
|
||||
(4, null, null);
|
||||
|
||||
query IIII
|
||||
SELECT c1, c3, c2, LAG(c3, c2, BITSTRING'010101010') OVER (PARTITION BY c1 ORDER BY c3) FROM issue17266 ORDER BY c1;
|
||||
----
|
||||
0 NULL NULL NULL
|
||||
1 101 32767 010101010
|
||||
2 101 -32767 010101010
|
||||
3 000 0 000
|
||||
4 NULL NULL NULL
|
||||
|
||||
query IIII
|
||||
SELECT c1, c3, c2, LEAD(c3, c2, BITSTRING'010101010') OVER (PARTITION BY c1 ORDER BY c3) FROM issue17266 ORDER BY c1;
|
||||
----
|
||||
0 NULL NULL NULL
|
||||
1 101 32767 010101010
|
||||
2 101 -32767 010101010
|
||||
3 000 0 000
|
||||
4 NULL NULL NULL
|
||||
102
external/duckdb/test/sql/window/test_leadlag_orderby.test
vendored
Normal file
102
external/duckdb/test/sql/window/test_leadlag_orderby.test
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# name: test/sql/window/test_leadlag_orderby.test
|
||||
# description: Test secondary ordering of LEAD/LAG
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query IIIII
|
||||
SELECT
|
||||
i,
|
||||
(i * 29) % 11 AS outside,
|
||||
i // 2 AS inside,
|
||||
lead(i, 1, NULL ORDER BY inside DESC, i) OVER w,
|
||||
lag(i, 1, NULL ORDER BY inside DESC, i) OVER w,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY outside
|
||||
)
|
||||
ORDER BY inside DESC, i
|
||||
----
|
||||
8 1 4 0 NULL
|
||||
9 8 4 7 8
|
||||
6 9 3 7 9
|
||||
7 5 3 5 8
|
||||
4 6 2 5 7
|
||||
5 2 2 0 8
|
||||
2 3 1 0 5
|
||||
3 10 1 0 2
|
||||
0 0 0 NULL NULL
|
||||
1 7 0 NULL 0
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
i,
|
||||
i // 2 AS inside,
|
||||
lead(i, 1, NULL ORDER BY i // 2, i) OVER w AS next,
|
||||
lag(i, 1, NULL ORDER BY i // 2, i) OVER w AS prev,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
)
|
||||
ORDER BY i
|
||||
----
|
||||
0 0 1 NULL
|
||||
1 0 2 0
|
||||
2 1 3 1
|
||||
3 1 4 2
|
||||
4 2 5 3
|
||||
5 2 6 4
|
||||
6 3 7 5
|
||||
7 3 8 6
|
||||
8 4 9 7
|
||||
9 4 NULL 8
|
||||
|
||||
# test lag and lead when offset is null
|
||||
statement ok
|
||||
CREATE TABLE issue17266(c1 INT, c2 SMALLINT, c3 BITSTRING);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue17266 VALUES
|
||||
(0, null, null),
|
||||
(1, 32767, '101'),
|
||||
(2, -32767, '101'),
|
||||
(3, 0, '000'),
|
||||
(4, 1, '010'),
|
||||
(5, 0, '110'),
|
||||
(6, null, null);
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
c1,
|
||||
c3,
|
||||
c2,
|
||||
LAG(c3, c2 ORDER BY c1, BITSTRING'010101010') OVER (PARTITION BY c1 ORDER BY c3)
|
||||
FROM issue17266
|
||||
ORDER BY c1;
|
||||
----
|
||||
0 NULL NULL NULL
|
||||
1 101 32767 NULL
|
||||
2 101 -32767 NULL
|
||||
3 000 0 000
|
||||
4 010 1 NULL
|
||||
5 110 0 110
|
||||
6 NULL NULL NULL
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
c1,
|
||||
c3,
|
||||
c2,
|
||||
LEAD(c3, c2 ORDER BY c1, BITSTRING'010101010') OVER (PARTITION BY c1 ORDER BY c3)
|
||||
FROM issue17266
|
||||
ORDER BY c1;
|
||||
----
|
||||
0 NULL NULL NULL
|
||||
1 101 32767 NULL
|
||||
2 101 -32767 NULL
|
||||
3 000 0 000
|
||||
4 010 1 NULL
|
||||
5 110 0 110
|
||||
6 NULL NULL NULL
|
||||
127
external/duckdb/test/sql/window/test_list_window.test
vendored
Normal file
127
external/duckdb/test/sql/window/test_list_window.test
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# name: test/sql/window/test_list_window.test
|
||||
# description: Test aggregate list
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE list_extract_test(i INTEGER, g INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO list_extract_test VALUES (1, 1), (2, 1), (3, 2), (NULL, 3), (42, 3);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW list_window AS
|
||||
SELECT g, LIST(i) OVER (PARTITION BY g ORDER BY i ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as l
|
||||
FROM list_extract_test;
|
||||
|
||||
query II
|
||||
SELECT * FROM list_window ORDER BY g
|
||||
----
|
||||
1 [1, 2]
|
||||
1 [1, 2]
|
||||
2 [3]
|
||||
3 [NULL, 42]
|
||||
3 [NULL, 42]
|
||||
|
||||
query I
|
||||
SELECT FIRST(LIST_EXTRACT(l, 1)) FROM list_window GROUP BY g ORDER BY g;
|
||||
----
|
||||
1
|
||||
3
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT FIRST(LIST_EXTRACT(l, 2)) FROM list_window GROUP BY g ORDER BY g;
|
||||
----
|
||||
2
|
||||
NULL
|
||||
42
|
||||
|
||||
query I
|
||||
SELECT FIRST(LIST_EXTRACT(l, 3)) FROM list_window GROUP BY g ORDER BY g;
|
||||
----
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
statement ok
|
||||
create table list_combine_test as
|
||||
select range%3 j,
|
||||
range::varchar AS s,
|
||||
case when range%3=0 then '-' else '|' end sep
|
||||
from range(1, 65)
|
||||
|
||||
query III
|
||||
select j, s, list(s) over (partition by j order by s)
|
||||
from list_combine_test
|
||||
order by j, s;
|
||||
----
|
||||
0 12 [12]
|
||||
0 15 [12, 15]
|
||||
0 18 [12, 15, 18]
|
||||
0 21 [12, 15, 18, 21]
|
||||
0 24 [12, 15, 18, 21, 24]
|
||||
0 27 [12, 15, 18, 21, 24, 27]
|
||||
0 3 [12, 15, 18, 21, 24, 27, 3]
|
||||
0 30 [12, 15, 18, 21, 24, 27, 3, 30]
|
||||
0 33 [12, 15, 18, 21, 24, 27, 3, 30, 33]
|
||||
0 36 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36]
|
||||
0 39 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39]
|
||||
0 42 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42]
|
||||
0 45 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45]
|
||||
0 48 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48]
|
||||
0 51 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51]
|
||||
0 54 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54]
|
||||
0 57 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57]
|
||||
0 6 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 6]
|
||||
0 60 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 6, 60]
|
||||
0 63 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 6, 60, 63]
|
||||
0 9 [12, 15, 18, 21, 24, 27, 3, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 6, 60, 63, 9]
|
||||
1 1 [1]
|
||||
1 10 [1, 10]
|
||||
1 13 [1, 10, 13]
|
||||
1 16 [1, 10, 13, 16]
|
||||
1 19 [1, 10, 13, 16, 19]
|
||||
1 22 [1, 10, 13, 16, 19, 22]
|
||||
1 25 [1, 10, 13, 16, 19, 22, 25]
|
||||
1 28 [1, 10, 13, 16, 19, 22, 25, 28]
|
||||
1 31 [1, 10, 13, 16, 19, 22, 25, 28, 31]
|
||||
1 34 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34]
|
||||
1 37 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37]
|
||||
1 4 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4]
|
||||
1 40 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40]
|
||||
1 43 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43]
|
||||
1 46 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46]
|
||||
1 49 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49]
|
||||
1 52 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52]
|
||||
1 55 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52, 55]
|
||||
1 58 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52, 55, 58]
|
||||
1 61 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52, 55, 58, 61]
|
||||
1 64 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52, 55, 58, 61, 64]
|
||||
1 7 [1, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 4, 40, 43, 46, 49, 52, 55, 58, 61, 64, 7]
|
||||
2 11 [11]
|
||||
2 14 [11, 14]
|
||||
2 17 [11, 14, 17]
|
||||
2 2 [11, 14, 17, 2]
|
||||
2 20 [11, 14, 17, 2, 20]
|
||||
2 23 [11, 14, 17, 2, 20, 23]
|
||||
2 26 [11, 14, 17, 2, 20, 23, 26]
|
||||
2 29 [11, 14, 17, 2, 20, 23, 26, 29]
|
||||
2 32 [11, 14, 17, 2, 20, 23, 26, 29, 32]
|
||||
2 35 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35]
|
||||
2 38 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38]
|
||||
2 41 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41]
|
||||
2 44 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44]
|
||||
2 47 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47]
|
||||
2 5 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5]
|
||||
2 50 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50]
|
||||
2 53 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50, 53]
|
||||
2 56 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50, 53, 56]
|
||||
2 59 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50, 53, 56, 59]
|
||||
2 62 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50, 53, 56, 59, 62]
|
||||
2 8 [11, 14, 17, 2, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 5, 50, 53, 56, 59, 62, 8]
|
||||
268
external/duckdb/test/sql/window/test_mad_window.test
vendored
Normal file
268
external/duckdb/test/sql/window/test_mad_window.test
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
# name: test/sql/window/test_mad_window.test
|
||||
# description: Test MAD aggregate as a window function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table mads as select range r from range(20) union all values (NULL), (NULL), (NULL);
|
||||
|
||||
query IIII
|
||||
SELECT r % 2 as p, r, r/3.0, mad(r/3.0) over (partition by r % 2 order by r)
|
||||
FROM mads ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0.000000 0.000000
|
||||
0 2 0.666667 0.333333
|
||||
0 4 1.333333 0.666667
|
||||
0 6 2.000000 0.666667
|
||||
0 8 2.666667 0.666667
|
||||
0 10 3.333333 1.000000
|
||||
0 12 4.000000 1.333333
|
||||
0 14 4.666667 1.333333
|
||||
0 16 5.333333 1.333333
|
||||
0 18 6.000000 1.666667
|
||||
1 1 0.333333 0.000000
|
||||
1 3 1.000000 0.333333
|
||||
1 5 1.666667 0.666667
|
||||
1 7 2.333333 0.666667
|
||||
1 9 3.000000 0.666667
|
||||
1 11 3.666667 1.000000
|
||||
1 13 4.333333 1.333333
|
||||
1 15 5.000000 1.333333
|
||||
1 17 5.666667 1.333333
|
||||
1 19 6.333333 1.666667
|
||||
|
||||
query III
|
||||
SELECT r, r/3.0, mad(r/3.0) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM mads ORDER BY 1, 2, 3
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0.000000
|
||||
0 0.000000 0.166667
|
||||
1 0.333333 0.333333
|
||||
2 0.666667 0.333333
|
||||
3 1.000000 0.333333
|
||||
4 1.333333 0.333333
|
||||
5 1.666667 0.333333
|
||||
6 2.000000 0.333333
|
||||
7 2.333333 0.333333
|
||||
8 2.666667 0.333333
|
||||
9 3.000000 0.333333
|
||||
10 3.333333 0.333333
|
||||
11 3.666667 0.333333
|
||||
12 4.000000 0.333333
|
||||
13 4.333333 0.333333
|
||||
14 4.666667 0.333333
|
||||
15 5.000000 0.333333
|
||||
16 5.333333 0.333333
|
||||
17 5.666667 0.333333
|
||||
18 6.000000 0.333333
|
||||
19 6.333333 0.166667
|
||||
|
||||
query III
|
||||
SELECT r, r/3.0, mad(r/3.0) over (order by r rows between 1 preceding and 3 following) FROM mads ORDER BY 1, 2, 3
|
||||
----
|
||||
NULL NULL 0.000000
|
||||
NULL NULL 0.166667
|
||||
NULL NULL 0.333333
|
||||
0 0.000000 0.333333
|
||||
1 0.333333 0.333333
|
||||
2 0.666667 0.333333
|
||||
3 1.000000 0.333333
|
||||
4 1.333333 0.333333
|
||||
5 1.666667 0.333333
|
||||
6 2.000000 0.333333
|
||||
7 2.333333 0.333333
|
||||
8 2.666667 0.333333
|
||||
9 3.000000 0.333333
|
||||
10 3.333333 0.333333
|
||||
11 3.666667 0.333333
|
||||
12 4.000000 0.333333
|
||||
13 4.333333 0.333333
|
||||
14 4.666667 0.333333
|
||||
15 5.000000 0.333333
|
||||
16 5.333333 0.333333
|
||||
17 5.666667 0.333333
|
||||
18 6.000000 0.333333
|
||||
19 6.333333 0.166667
|
||||
|
||||
# Scattered NULLs
|
||||
query IIII
|
||||
SELECT r % 3 as p, r, n, mad(n) over (partition by r % 3 order by r)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM mads) nulls
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0 0.000000
|
||||
0 3 NULL 0.000000
|
||||
0 6 6 3.000000
|
||||
0 9 NULL 3.000000
|
||||
0 12 12 6.000000
|
||||
0 15 NULL 6.000000
|
||||
0 18 18 6.000000
|
||||
1 1 NULL NULL
|
||||
1 4 4 0.000000
|
||||
1 7 NULL 0.000000
|
||||
1 10 10 3.000000
|
||||
1 13 NULL 3.000000
|
||||
1 16 16 6.000000
|
||||
1 19 NULL 6.000000
|
||||
2 2 2 0.000000
|
||||
2 5 NULL 0.000000
|
||||
2 8 8 3.000000
|
||||
2 11 NULL 3.000000
|
||||
2 14 14 6.000000
|
||||
2 17 NULL 6.000000
|
||||
|
||||
query III
|
||||
SELECT r, n, mad(n) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM mads) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0.000000
|
||||
0 0 0.000000
|
||||
1 NULL 1.000000
|
||||
2 2 0.000000
|
||||
3 NULL 1.000000
|
||||
4 4 0.000000
|
||||
5 NULL 1.000000
|
||||
6 6 0.000000
|
||||
7 NULL 1.000000
|
||||
8 8 0.000000
|
||||
9 NULL 1.000000
|
||||
10 10 0.000000
|
||||
11 NULL 1.000000
|
||||
12 12 0.000000
|
||||
13 NULL 1.000000
|
||||
14 14 0.000000
|
||||
15 NULL 1.000000
|
||||
16 16 0.000000
|
||||
17 NULL 1.000000
|
||||
18 18 0.000000
|
||||
19 NULL 0.000000
|
||||
|
||||
query III
|
||||
SELECT r, n, mad(n) over (order by r rows between 1 preceding and 3 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM mads) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 0.000000
|
||||
NULL NULL 0.000000
|
||||
NULL NULL 1.000000
|
||||
0 0 1.000000
|
||||
1 NULL 2.000000
|
||||
2 2 1.000000
|
||||
3 NULL 2.000000
|
||||
4 4 1.000000
|
||||
5 NULL 2.000000
|
||||
6 6 1.000000
|
||||
7 NULL 2.000000
|
||||
8 8 1.000000
|
||||
9 NULL 2.000000
|
||||
10 10 1.000000
|
||||
11 NULL 2.000000
|
||||
12 12 1.000000
|
||||
13 NULL 2.000000
|
||||
14 14 1.000000
|
||||
15 NULL 2.000000
|
||||
16 16 1.000000
|
||||
17 NULL 1.000000
|
||||
18 18 0.000000
|
||||
19 NULL 0.000000
|
||||
|
||||
query III
|
||||
SELECT r, n, mad(n) over (order by r rows between unbounded preceding and unbounded following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM mads) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 5.000000
|
||||
NULL NULL 5.000000
|
||||
NULL NULL 5.000000
|
||||
0 0 5.000000
|
||||
1 NULL 5.000000
|
||||
2 2 5.000000
|
||||
3 NULL 5.000000
|
||||
4 4 5.000000
|
||||
5 NULL 5.000000
|
||||
6 6 5.000000
|
||||
7 NULL 5.000000
|
||||
8 8 5.000000
|
||||
9 NULL 5.000000
|
||||
10 10 5.000000
|
||||
11 NULL 5.000000
|
||||
12 12 5.000000
|
||||
13 NULL 5.000000
|
||||
14 14 5.000000
|
||||
15 NULL 5.000000
|
||||
16 16 5.000000
|
||||
17 NULL 5.000000
|
||||
18 18 5.000000
|
||||
19 NULL 5.000000
|
||||
|
||||
#
|
||||
# ReplaceIndex coverage
|
||||
#
|
||||
statement ok
|
||||
CREATE TABLE coverage AS SELECT * FROM (VALUES
|
||||
(1), (2), (3), (1)
|
||||
) tbl(r)
|
||||
|
||||
query II
|
||||
SELECT r, mad(r) OVER (ORDER BY r ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
|
||||
FROM coverage
|
||||
ORDER BY 1
|
||||
----
|
||||
1 0.000000
|
||||
1 0.000000
|
||||
2 1.000000
|
||||
3 0.500000
|
||||
|
||||
#
|
||||
# Compare implementations
|
||||
#
|
||||
foreach windowmode "window" "combine" "separate"
|
||||
|
||||
statement ok
|
||||
PRAGMA debug_window_mode=${windowmode}
|
||||
|
||||
query IIII
|
||||
SELECT r % 2 as p, r, r/3.0, mad(r/3.0) over (partition by r % 2 order by r)
|
||||
FROM mads ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0.000000 0.000000
|
||||
0 2 0.666667 0.333333
|
||||
0 4 1.333333 0.666667
|
||||
0 6 2.000000 0.666667
|
||||
0 8 2.666667 0.666667
|
||||
0 10 3.333333 1.000000
|
||||
0 12 4.000000 1.333333
|
||||
0 14 4.666667 1.333333
|
||||
0 16 5.333333 1.333333
|
||||
0 18 6.000000 1.666667
|
||||
1 1 0.333333 0.000000
|
||||
1 3 1.000000 0.333333
|
||||
1 5 1.666667 0.666667
|
||||
1 7 2.333333 0.666667
|
||||
1 9 3.000000 0.666667
|
||||
1 11 3.666667 1.000000
|
||||
1 13 4.333333 1.333333
|
||||
1 15 5.000000 1.333333
|
||||
1 17 5.666667 1.333333
|
||||
1 19 6.333333 1.666667
|
||||
|
||||
endloop
|
||||
177
external/duckdb/test/sql/window/test_mode_window.test
vendored
Normal file
177
external/duckdb/test/sql/window/test_mode_window.test
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
# name: test/sql/window/test_mode_window.test
|
||||
# description: Test MODE aggregate as a window function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_external
|
||||
|
||||
statement ok
|
||||
create table modes as select range r from range(10) union all values (NULL), (NULL), (NULL);
|
||||
|
||||
query IIII
|
||||
SELECT r % 2, r, r//3, mode(r//3) over (partition by r % 2 order by r) FROM modes ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0 0
|
||||
0 2 0 0
|
||||
0 4 1 0
|
||||
0 6 2 0
|
||||
0 8 2 0
|
||||
1 1 0 0
|
||||
1 3 1 0
|
||||
1 5 1 1
|
||||
1 7 2 1
|
||||
1 9 3 1
|
||||
|
||||
query III
|
||||
SELECT r, r//3, mode(r//3) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM modes
|
||||
ORDER BY ALL
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 0 0
|
||||
2 0 0
|
||||
3 1 1
|
||||
4 1 1
|
||||
5 1 1
|
||||
6 2 2
|
||||
7 2 2
|
||||
8 2 2
|
||||
9 3 2
|
||||
|
||||
query III
|
||||
SELECT r, r//3, mode(r//3) over (order by r rows between 1 preceding and 3 following) FROM modes ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 0 0
|
||||
2 0 1
|
||||
3 1 1
|
||||
4 1 1
|
||||
5 1 2
|
||||
6 2 2
|
||||
7 2 2
|
||||
8 2 2
|
||||
9 3 2
|
||||
|
||||
# Scattered NULLs
|
||||
query IIII
|
||||
SELECT r, r // 3, n, mode(n) over (partition by r % 3 order by r)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM modes) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0 0
|
||||
1 0 NULL NULL
|
||||
2 0 2 2
|
||||
3 1 NULL 0
|
||||
4 1 4 4
|
||||
5 1 NULL 2
|
||||
6 2 6 0
|
||||
7 2 NULL 4
|
||||
8 2 8 2
|
||||
9 3 NULL 0
|
||||
|
||||
query III
|
||||
SELECT r, n, mode(n) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM modes) nulls
|
||||
ORDER BY ALL
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 NULL 0
|
||||
2 2 2
|
||||
3 NULL 2
|
||||
4 4 4
|
||||
5 NULL 4
|
||||
6 6 6
|
||||
7 NULL 6
|
||||
8 8 8
|
||||
9 NULL 8
|
||||
|
||||
query III
|
||||
SELECT r, n, mode(n) over (order by r rows between 1 preceding and 3 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM modes) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 NULL 0
|
||||
2 2 2
|
||||
3 NULL 2
|
||||
4 4 4
|
||||
5 NULL 4
|
||||
6 6 6
|
||||
7 NULL 6
|
||||
8 8 8
|
||||
9 NULL 8
|
||||
|
||||
query III
|
||||
SELECT r, n, mode(n) over (order by r rows between unbounded preceding and unbounded following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM modes) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 NULL 0
|
||||
2 2 0
|
||||
3 NULL 0
|
||||
4 4 0
|
||||
5 NULL 0
|
||||
6 6 0
|
||||
7 NULL 0
|
||||
8 8 0
|
||||
9 NULL 0
|
||||
|
||||
#
|
||||
# Compare implementations
|
||||
#
|
||||
|
||||
foreach windowmode "window" "combine" "separate"
|
||||
|
||||
statement ok
|
||||
PRAGMA debug_window_mode=${windowmode}
|
||||
|
||||
query III
|
||||
WITH t(r) AS (VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9), (NULL), (NULL), (NULL))
|
||||
SELECT r, r//3, mode(r//3) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM t
|
||||
ORDER BY ALL
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0
|
||||
0 0 0
|
||||
1 0 0
|
||||
2 0 0
|
||||
3 1 1
|
||||
4 1 1
|
||||
5 1 1
|
||||
6 2 2
|
||||
7 2 2
|
||||
8 2 2
|
||||
9 3 2
|
||||
|
||||
endloop
|
||||
|
||||
374
external/duckdb/test/sql/window/test_naive_aggregation.test
vendored
Normal file
374
external/duckdb/test/sql/window/test_naive_aggregation.test
vendored
Normal file
@@ -0,0 +1,374 @@
|
||||
# name: test/sql/window/test_naive_aggregation.test
|
||||
# description: Test naive aggregation implementation
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA debug_window_mode=separate
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date)
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15')
|
||||
|
||||
# basic example from postgres' window.sql
|
||||
query TIIR
|
||||
SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname ORDER BY empno) FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 7 4200 4200.000000
|
||||
develop 8 6000 10200.000000
|
||||
develop 9 4500 14700.000000
|
||||
develop 10 5200 19900.000000
|
||||
develop 11 5200 25100.000000
|
||||
personnel 2 3900 3900.000000
|
||||
personnel 5 3500 7400.000000
|
||||
sales 1 5000 5000.000000
|
||||
sales 3 4800 9800.000000
|
||||
sales 4 4800 14600.000000
|
||||
|
||||
# sum
|
||||
query R
|
||||
SELECT sum(salary) OVER (PARTITION BY depname ORDER BY salary) ss FROM empsalary ORDER BY depname, ss
|
||||
----
|
||||
4200.000000
|
||||
8700.000000
|
||||
19100.000000
|
||||
19100.000000
|
||||
25100.000000
|
||||
3500.000000
|
||||
7400.000000
|
||||
9600.000000
|
||||
9600.000000
|
||||
14600.000000
|
||||
|
||||
# min/max/avg
|
||||
query TIIR
|
||||
SELECT depname, min(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m1, max(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m2, AVG(salary) OVER (PARTITION BY depname ORDER BY salary, empno) m3 FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 4200 4200 4200.000000
|
||||
develop 4200 6000 5020.000000
|
||||
develop 4200 4500 4350.000000
|
||||
develop 4200 5200 4633.333333
|
||||
develop 4200 5200 4775.000000
|
||||
personnel 3500 3900 3700.000000
|
||||
personnel 3500 3500 3500.000000
|
||||
sales 4800 5000 4866.666667
|
||||
sales 4800 4800 4800.000000
|
||||
sales 4800 4800 4800.000000
|
||||
|
||||
# stddev_pop
|
||||
query TR
|
||||
SELECT depname, STDDEV_POP(salary) OVER (PARTITION BY depname ORDER BY salary, empno) s FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 0.000000
|
||||
develop 627.375486
|
||||
develop 150.000000
|
||||
develop 418.993503
|
||||
develop 438.035387
|
||||
personnel 200.000000
|
||||
personnel 0.000000
|
||||
sales 94.280904
|
||||
sales 0.000000
|
||||
sales 0.000000
|
||||
|
||||
# covar_pop
|
||||
query TR
|
||||
SELECT depname, COVAR_POP(salary, empno) OVER (PARTITION BY depname ORDER BY salary, empno) c FROM empsalary ORDER BY depname, empno
|
||||
----
|
||||
develop 0.000000
|
||||
develop 240.000000
|
||||
develop 150.000000
|
||||
develop 477.777778
|
||||
develop 606.250000
|
||||
personnel -300.000000
|
||||
personnel 0.000000
|
||||
sales -111.111111
|
||||
sales 0.000000
|
||||
sales 0.000000
|
||||
|
||||
statement ok
|
||||
CREATE TABLE filtering AS
|
||||
SELECT
|
||||
x
|
||||
,round(x * 0.333,0) % 3 AS y
|
||||
,round(x * 0.333,0) % 3 AS z
|
||||
FROM generate_series(0,10) tbl(x);
|
||||
|
||||
# The x_filtered_window and z_filtered_window columns should return a different output than plain_window
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,avg(x) OVER (PARTITION BY y) AS plain_window
|
||||
,avg(x) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,avg(x) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM filtering
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
1 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
8 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
9 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
10 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
2 1.000000 1.000000 3.000000 NULL NULL
|
||||
3 1.000000 1.000000 3.000000 NULL NULL
|
||||
4 1.000000 1.000000 3.000000 NULL NULL
|
||||
5 2.000000 2.000000 6.000000 NULL NULL
|
||||
6 2.000000 2.000000 6.000000 NULL NULL
|
||||
7 2.000000 2.000000 6.000000 NULL NULL
|
||||
|
||||
# COUNT(*) coverage
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,count(*) OVER (PARTITION BY y) AS plain_window
|
||||
,count(*) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,count(*) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM filtering
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 5 1 5
|
||||
1 0.000000 0.000000 5 1 5
|
||||
8 0.000000 0.000000 5 1 5
|
||||
9 0.000000 0.000000 5 1 5
|
||||
10 0.000000 0.000000 5 1 5
|
||||
2 1.000000 1.000000 3 0 0
|
||||
3 1.000000 1.000000 3 0 0
|
||||
4 1.000000 1.000000 3 0 0
|
||||
5 2.000000 2.000000 3 0 0
|
||||
6 2.000000 2.000000 3 0 0
|
||||
7 2.000000 2.000000 3 0 0
|
||||
|
||||
# Holistic coverage
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,median(x) OVER (PARTITION BY y) AS plain_window
|
||||
,median(x) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,median(x) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM filtering
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
1 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
8 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
9 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
10 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
2 1.000000 1.000000 3.000000 NULL NULL
|
||||
3 1.000000 1.000000 3.000000 NULL NULL
|
||||
4 1.000000 1.000000 3.000000 NULL NULL
|
||||
5 2.000000 2.000000 6.000000 NULL NULL
|
||||
6 2.000000 2.000000 6.000000 NULL NULL
|
||||
7 2.000000 2.000000 6.000000 NULL NULL
|
||||
|
||||
# Filters do not affect framing.
|
||||
query II
|
||||
SELECT x, count(x) FILTER (WHERE x % 2 = 0) OVER (ORDER BY x ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
|
||||
FROM generate_series(0,10) tbl(x);
|
||||
----
|
||||
0 2
|
||||
1 2
|
||||
2 3
|
||||
3 2
|
||||
4 3
|
||||
5 2
|
||||
6 3
|
||||
7 2
|
||||
8 3
|
||||
9 2
|
||||
10 2
|
||||
|
||||
# Test distinct hash table
|
||||
statement ok
|
||||
CREATE TABLE figure1 AS
|
||||
SELECT *
|
||||
FROM VALUES
|
||||
(1, 'a'),
|
||||
(2, 'b'),
|
||||
(3, 'b'),
|
||||
(4, 'c'),
|
||||
(5, 'c'),
|
||||
(6, 'b'),
|
||||
(7, 'c'),
|
||||
(8, 'a')
|
||||
v(i, s);
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) OVER( ORDER BY i ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM figure1
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 2
|
||||
2 b 3
|
||||
3 b 3
|
||||
4 c 2
|
||||
5 c 2
|
||||
6 b 3
|
||||
7 c 3
|
||||
8 a 3
|
||||
|
||||
# Test distinct and exclude
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) OVER( ORDER BY i ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING EXCLUDE TIES) AS c
|
||||
FROM figure1
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 2
|
||||
2 b 3
|
||||
3 b 3
|
||||
4 c 2
|
||||
5 c 2
|
||||
6 b 3
|
||||
7 c 3
|
||||
8 a 3
|
||||
|
||||
# Test ORDER BY arguments
|
||||
# Multiple partitions => multiple threads.
|
||||
query III
|
||||
SELECT
|
||||
i // 10 AS p,
|
||||
i,
|
||||
ANY_VALUE(i ORDER BY i DESC) OVER(
|
||||
PARTITION BY i // 10
|
||||
ORDER BY i
|
||||
ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING
|
||||
) AS c
|
||||
FROM range(20) tbl(i)
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 0 2
|
||||
0 1 3
|
||||
0 2 4
|
||||
0 3 5
|
||||
0 4 6
|
||||
0 5 7
|
||||
0 6 8
|
||||
0 7 9
|
||||
0 8 9
|
||||
0 9 9
|
||||
1 10 12
|
||||
1 11 13
|
||||
1 12 14
|
||||
1 13 15
|
||||
1 14 16
|
||||
1 15 17
|
||||
1 16 18
|
||||
1 17 19
|
||||
1 18 19
|
||||
1 19 19
|
||||
|
||||
query III
|
||||
SELECT
|
||||
i // 10 AS p,
|
||||
i,
|
||||
LIST(i ORDER BY i DESC) OVER(
|
||||
PARTITION BY i // 10
|
||||
ORDER BY i
|
||||
ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING
|
||||
) AS c
|
||||
FROM range(20) tbl(i)
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 0 [2, 1, 0]
|
||||
0 1 [3, 2, 1, 0]
|
||||
0 2 [4, 3, 2, 1, 0]
|
||||
0 3 [5, 4, 3, 2, 1]
|
||||
0 4 [6, 5, 4, 3, 2]
|
||||
0 5 [7, 6, 5, 4, 3]
|
||||
0 6 [8, 7, 6, 5, 4]
|
||||
0 7 [9, 8, 7, 6, 5]
|
||||
0 8 [9, 8, 7, 6]
|
||||
0 9 [9, 8, 7]
|
||||
1 10 [12, 11, 10]
|
||||
1 11 [13, 12, 11, 10]
|
||||
1 12 [14, 13, 12, 11, 10]
|
||||
1 13 [15, 14, 13, 12, 11]
|
||||
1 14 [16, 15, 14, 13, 12]
|
||||
1 15 [17, 16, 15, 14, 13]
|
||||
1 16 [18, 17, 16, 15, 14]
|
||||
1 17 [19, 18, 17, 16, 15]
|
||||
1 18 [19, 18, 17, 16]
|
||||
1 19 [19, 18, 17]
|
||||
|
||||
# Test DISTINCT + ORDER BY arguments
|
||||
query III
|
||||
SELECT
|
||||
i // 10 AS p,
|
||||
i,
|
||||
LIST(DISTINCT i // 2 ORDER BY i DESC) OVER(
|
||||
PARTITION BY i // 10
|
||||
ORDER BY i
|
||||
ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING
|
||||
) AS c
|
||||
FROM range(20) tbl(i)
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 0 [1, 0]
|
||||
0 1 [1, 0]
|
||||
0 2 [2, 1, 0]
|
||||
0 3 [2, 1, 0]
|
||||
0 4 [3, 2, 1]
|
||||
0 5 [3, 2, 1]
|
||||
0 6 [4, 3, 2]
|
||||
0 7 [4, 3, 2]
|
||||
0 8 [4, 3]
|
||||
0 9 [4, 3]
|
||||
1 10 [6, 5]
|
||||
1 11 [6, 5]
|
||||
1 12 [7, 6, 5]
|
||||
1 13 [7, 6, 5]
|
||||
1 14 [8, 7, 6]
|
||||
1 15 [8, 7, 6]
|
||||
1 16 [9, 8, 7]
|
||||
1 17 [9, 8, 7]
|
||||
1 18 [9, 8]
|
||||
1 19 [9, 8]
|
||||
|
||||
# Test DISTINCT + ORDER BY + FILTER arguments
|
||||
query III
|
||||
SELECT
|
||||
i // 10 AS p,
|
||||
i,
|
||||
LIST(DISTINCT i // 2 ORDER BY i DESC) FILTER (i > 1) OVER(
|
||||
PARTITION BY i // 10
|
||||
ORDER BY i
|
||||
ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING
|
||||
) AS c
|
||||
FROM range(20) tbl(i)
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 0 [1]
|
||||
0 1 [1]
|
||||
0 2 [2, 1]
|
||||
0 3 [2, 1]
|
||||
0 4 [3, 2, 1]
|
||||
0 5 [3, 2, 1]
|
||||
0 6 [4, 3, 2]
|
||||
0 7 [4, 3, 2]
|
||||
0 8 [4, 3]
|
||||
0 9 [4, 3]
|
||||
1 10 [6, 5]
|
||||
1 11 [6, 5]
|
||||
1 12 [7, 6, 5]
|
||||
1 13 [7, 6, 5]
|
||||
1 14 [8, 7, 6]
|
||||
1 15 [8, 7, 6]
|
||||
1 16 [9, 8, 7]
|
||||
1 17 [9, 8, 7]
|
||||
1 18 [9, 8]
|
||||
1 19 [9, 8]
|
||||
63
external/duckdb/test/sql/window/test_negative_range.test
vendored
Normal file
63
external/duckdb/test/sql/window/test_negative_range.test
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# name: test/sql/window/test_negative_range.test
|
||||
# description: Check that negative ranges trigger errors
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE issue10855(i INTEGER, v FLOAT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue10855 VALUES (0, 1), (1, 2), (2, 3),;
|
||||
|
||||
# Ascending
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE FOLLOWING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i RANGE BETWEEN -1 FOLLOWING AND 1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE FOLLOWING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE PRECEDING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i RANGE BETWEEN 1 PRECEDING AND -1 PRECEDING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE PRECEDING value
|
||||
|
||||
# Descending
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i DESC RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE FOLLOWING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i DESC RANGE BETWEEN -1 FOLLOWING AND 1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE FOLLOWING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i DESC RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE PRECEDING value
|
||||
|
||||
statement error
|
||||
SELECT i, v, sum(v) OVER (ORDER BY i DESC RANGE BETWEEN 1 PRECEDING AND -1 PRECEDING)
|
||||
FROM issue10855
|
||||
----
|
||||
Out of Range Error: Invalid RANGE PRECEDING value
|
||||
|
||||
138
external/duckdb/test/sql/window/test_no_default_window_spec.test
vendored
Normal file
138
external/duckdb/test/sql/window/test_no_default_window_spec.test
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
# name: test/sql/window/test_no_default_window_spec.test
|
||||
# description: Non-default window specs
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table tenk1d(ten int4, four int4)
|
||||
|
||||
statement ok
|
||||
insert into tenk1d values (0,0), (1,1), (3,3), (2,2), (4,2), (9,1), (4,0), (7,3), (0,2), (2,0), (5,1), (1,3), (3,1), (6,0), (8,0), (9,3), (8,2), (6,2), (7,1), (5,3)
|
||||
|
||||
# BASIC
|
||||
query IIRI
|
||||
SELECT four, ten, sum(ten) over (partition by four order by ten) st, last_value(ten) over (partition by four order by ten) lt FROM tenk1d ORDER BY four, ten
|
||||
----
|
||||
0 0 0.000000 0
|
||||
0 2 2.000000 2
|
||||
0 4 6.000000 4
|
||||
0 6 12.000000 6
|
||||
0 8 20.000000 8
|
||||
1 1 1.000000 1
|
||||
1 3 4.000000 3
|
||||
1 5 9.000000 5
|
||||
1 7 16.000000 7
|
||||
1 9 25.000000 9
|
||||
2 0 0.000000 0
|
||||
2 2 2.000000 2
|
||||
2 4 6.000000 4
|
||||
2 6 12.000000 6
|
||||
2 8 20.000000 8
|
||||
3 1 1.000000 1
|
||||
3 3 4.000000 3
|
||||
3 5 9.000000 5
|
||||
3 7 16.000000 7
|
||||
3 9 25.000000 9
|
||||
|
||||
# same but with explicit window def
|
||||
query IIRI
|
||||
SELECT four, ten, sum(ten) over (partition by four order by ten range between unbounded preceding and current row) st, last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) lt FROM tenk1d order by four, ten
|
||||
----
|
||||
0 0 0.000000 0
|
||||
0 2 2.000000 2
|
||||
0 4 6.000000 4
|
||||
0 6 12.000000 6
|
||||
0 8 20.000000 8
|
||||
1 1 1.000000 1
|
||||
1 3 4.000000 3
|
||||
1 5 9.000000 5
|
||||
1 7 16.000000 7
|
||||
1 9 25.000000 9
|
||||
2 0 0.000000 0
|
||||
2 2 2.000000 2
|
||||
2 4 6.000000 4
|
||||
2 6 12.000000 6
|
||||
2 8 20.000000 8
|
||||
3 1 1.000000 1
|
||||
3 3 4.000000 3
|
||||
3 5 9.000000 5
|
||||
3 7 16.000000 7
|
||||
3 9 25.000000 9
|
||||
|
||||
# unbounded following
|
||||
query IIRI
|
||||
SELECT four, ten, sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) st, last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) lt FROM tenk1d order by four, ten
|
||||
----
|
||||
0 0 20.000000 8
|
||||
0 2 20.000000 8
|
||||
0 4 20.000000 8
|
||||
0 6 20.000000 8
|
||||
0 8 20.000000 8
|
||||
1 1 25.000000 9
|
||||
1 3 25.000000 9
|
||||
1 5 25.000000 9
|
||||
1 7 25.000000 9
|
||||
1 9 25.000000 9
|
||||
2 0 20.000000 8
|
||||
2 2 20.000000 8
|
||||
2 4 20.000000 8
|
||||
2 6 20.000000 8
|
||||
2 8 20.000000 8
|
||||
3 1 25.000000 9
|
||||
3 3 25.000000 9
|
||||
3 5 25.000000 9
|
||||
3 7 25.000000 9
|
||||
3 9 25.000000 9
|
||||
|
||||
# unbounded following with expressions
|
||||
query IIRI
|
||||
SELECT four, ten//4 as two, sum(ten//4) over (partition by four order by ten//4 range between unbounded preceding and current row) st, last_value(ten//4) over (partition by four order by ten//4 range between unbounded preceding and current row) lt FROM tenk1d order by four, ten//4
|
||||
----
|
||||
0 0 0.000000 0
|
||||
0 0 0.000000 0
|
||||
0 1 2.000000 1
|
||||
0 1 2.000000 1
|
||||
0 2 4.000000 2
|
||||
1 0 0.000000 0
|
||||
1 0 0.000000 0
|
||||
1 1 2.000000 1
|
||||
1 1 2.000000 1
|
||||
1 2 4.000000 2
|
||||
2 0 0.000000 0
|
||||
2 0 0.000000 0
|
||||
2 1 2.000000 1
|
||||
2 1 2.000000 1
|
||||
2 2 4.000000 2
|
||||
3 0 0.000000 0
|
||||
3 0 0.000000 0
|
||||
3 1 2.000000 1
|
||||
3 1 2.000000 1
|
||||
3 2 4.000000 2
|
||||
|
||||
# unbounded following with named windows
|
||||
query IIRI
|
||||
SELECT four, ten//4 as two, sum(ten//4) OVER w st, last_value(ten//4) OVER w lt FROM tenk1d WINDOW w AS (partition by four order by ten//4 range between unbounded preceding and current row) order by four, ten//4
|
||||
----
|
||||
0 0 0.000000 0
|
||||
0 0 0.000000 0
|
||||
0 1 2.000000 1
|
||||
0 1 2.000000 1
|
||||
0 2 4.000000 2
|
||||
1 0 0.000000 0
|
||||
1 0 0.000000 0
|
||||
1 1 2.000000 1
|
||||
1 1 2.000000 1
|
||||
1 2 4.000000 2
|
||||
2 0 0.000000 0
|
||||
2 0 0.000000 0
|
||||
2 1 2.000000 1
|
||||
2 1 2.000000 1
|
||||
2 2 4.000000 2
|
||||
3 0 0.000000 0
|
||||
3 0 0.000000 0
|
||||
3 1 2.000000 1
|
||||
3 1 2.000000 1
|
||||
3 2 4.000000 2
|
||||
|
||||
204
external/duckdb/test/sql/window/test_nthvalue.test
vendored
Normal file
204
external/duckdb/test/sql/window/test_nthvalue.test
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
# name: test/sql/window/test_nthvalue.test
|
||||
# description: Most basic window function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date);
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15');
|
||||
|
||||
# nth_value
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(empno, 2) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 8
|
||||
develop 8 9
|
||||
develop 9 10
|
||||
develop 10 11
|
||||
develop 11 NULL
|
||||
personnel 2 5
|
||||
personnel 5 NULL
|
||||
sales 1 3
|
||||
sales 3 4
|
||||
sales 4 NULL
|
||||
|
||||
# Where either of the the parameters is a constant NULL
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(empno, NULL) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 NULL
|
||||
develop 8 NULL
|
||||
develop 9 NULL
|
||||
develop 10 NULL
|
||||
develop 11 NULL
|
||||
personnel 2 NULL
|
||||
personnel 5 NULL
|
||||
sales 1 NULL
|
||||
sales 3 NULL
|
||||
sales 4 NULL
|
||||
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(NULL, 2) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 NULL
|
||||
develop 8 NULL
|
||||
develop 9 NULL
|
||||
develop 10 NULL
|
||||
develop 11 NULL
|
||||
personnel 2 NULL
|
||||
personnel 5 NULL
|
||||
sales 1 NULL
|
||||
sales 3 NULL
|
||||
sales 4 NULL
|
||||
|
||||
# Where either of the parameters is a column that contains NULL values
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(empno, case empno % 3 when 1 then 2 else NULL end) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 8
|
||||
develop 8 NULL
|
||||
develop 9 NULL
|
||||
develop 10 11
|
||||
develop 11 NULL
|
||||
personnel 2 NULL
|
||||
personnel 5 NULL
|
||||
sales 1 3
|
||||
sales 3 NULL
|
||||
sales 4 NULL
|
||||
|
||||
statement ok
|
||||
CREATE VIEW empno_nulls AS
|
||||
SELECT depname, case empno % 2 when 1 then empno else NULL end as empno, salary, enroll_date
|
||||
FROM empsalary
|
||||
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(empno, 2) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empno_nulls
|
||||
ORDER BY 1, 2, 3
|
||||
----
|
||||
develop NULL NULL
|
||||
develop NULL 7
|
||||
develop 7 9
|
||||
develop 9 11
|
||||
develop 11 NULL
|
||||
personnel NULL 5
|
||||
personnel 5 NULL
|
||||
sales NULL 1
|
||||
sales 1 3
|
||||
sales 3 NULL
|
||||
|
||||
# Where the second parameter (offset) is not a constant
|
||||
query IIII
|
||||
SELECT depname, empno, 1 + empno %3 as offset,
|
||||
nth_value(empno, 1 + empno %3) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 2 8
|
||||
develop 8 3 10
|
||||
develop 9 1 9
|
||||
develop 10 2 11
|
||||
develop 11 3 NULL
|
||||
personnel 2 3 NULL
|
||||
personnel 5 3 NULL
|
||||
sales 1 2 3
|
||||
sales 3 1 3
|
||||
sales 4 2 NULL
|
||||
|
||||
# Where the second parameter (offset) can be zero (coverage)
|
||||
query IIII
|
||||
SELECT depname, empno, empno %3 as offset,
|
||||
nth_value(empno, empno %3) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 1 7
|
||||
develop 8 2 9
|
||||
develop 9 0 NULL
|
||||
develop 10 1 10
|
||||
develop 11 2 NULL
|
||||
personnel 2 2 5
|
||||
personnel 5 2 NULL
|
||||
sales 1 1 1
|
||||
sales 3 0 NULL
|
||||
sales 4 1 4
|
||||
|
||||
# Where the first parameter is a constant
|
||||
query III
|
||||
SELECT depname, empno,
|
||||
nth_value(-1, 2) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
develop 7 -1
|
||||
develop 8 -1
|
||||
develop 9 -1
|
||||
develop 10 -1
|
||||
develop 11 NULL
|
||||
personnel 2 -1
|
||||
personnel 5 NULL
|
||||
sales 1 -1
|
||||
sales 3 -1
|
||||
sales 4 NULL
|
||||
|
||||
statement error
|
||||
SELECT depname, empno,
|
||||
nth_value(empno) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT depname, empno,
|
||||
nth_value(empno, 2, 3) OVER (
|
||||
PARTITION BY depname ORDER BY empno ASC
|
||||
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
|
||||
) fv
|
||||
FROM empsalary
|
||||
----
|
||||
181
external/duckdb/test/sql/window/test_ntile.test
vendored
Normal file
181
external/duckdb/test/sql/window/test_ntile.test
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
# name: test/sql/window/test_ntile.test
|
||||
# description: Test NTile function
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE Scoreboard(TeamName VARCHAR, Player VARCHAR, Score INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Mongrels', 'Apu', 350);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Mongrels', 'Ned', 666);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Mongrels', 'Meg', 1030);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Mongrels', 'Burns', 1270);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Simpsons', 'Homer', 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Simpsons', 'Lisa', 710);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Simpsons', 'Marge', 990);
|
||||
|
||||
statement ok
|
||||
INSERT INTO Scoreboard VALUES ('Simpsons', 'Bart', 2010);
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(2) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
Mongrels Apu 350 1
|
||||
Mongrels Ned 666 1
|
||||
Mongrels Meg 1030 2
|
||||
Mongrels Burns 1270 2
|
||||
Simpsons Homer 1 1
|
||||
Simpsons Lisa 710 1
|
||||
Simpsons Marge 990 2
|
||||
Simpsons Bart 2010 2
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(2) OVER (ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY Score;
|
||||
----
|
||||
Simpsons Homer 1 1
|
||||
Mongrels Apu 350 1
|
||||
Mongrels Ned 666 1
|
||||
Simpsons Lisa 710 1
|
||||
Simpsons Marge 990 2
|
||||
Mongrels Meg 1030 2
|
||||
Mongrels Burns 1270 2
|
||||
Simpsons Bart 2010 2
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(1000) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
Mongrels Apu 350 1
|
||||
Mongrels Ned 666 2
|
||||
Mongrels Meg 1030 3
|
||||
Mongrels Burns 1270 4
|
||||
Simpsons Homer 1 1
|
||||
Simpsons Lisa 710 2
|
||||
Simpsons Marge 990 3
|
||||
Simpsons Bart 2010 4
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(1) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
Mongrels Apu 350 1
|
||||
Mongrels Ned 666 1
|
||||
Mongrels Meg 1030 1
|
||||
Mongrels Burns 1270 1
|
||||
Simpsons Homer 1 1
|
||||
Simpsons Lisa 710 1
|
||||
Simpsons Marge 990 1
|
||||
Simpsons Bart 2010 1
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(NULL) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
Mongrels Apu 350 NULL
|
||||
Mongrels Ned 666 NULL
|
||||
Mongrels Meg 1030 NULL
|
||||
Mongrels Burns 1270 NULL
|
||||
Simpsons Homer 1 NULL
|
||||
Simpsons Lisa 710 NULL
|
||||
Simpsons Marge 990 NULL
|
||||
Simpsons Bart 2010 NULL
|
||||
|
||||
# incorrect number of parameters for ntile
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE() OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(1,2) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(1,2,3) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(1,2,3,4) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(-1) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
TeamName,
|
||||
Player,
|
||||
Score,
|
||||
NTILE(0) OVER (PARTITION BY TeamName ORDER BY Score ASC) AS NTILE
|
||||
FROM ScoreBoard s
|
||||
ORDER BY TeamName, Score;
|
||||
----
|
||||
35
external/duckdb/test/sql/window/test_order_by_all.test
vendored
Normal file
35
external/duckdb/test/sql/window/test_order_by_all.test
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# name: test/sql/window/test_order_by_all.test
|
||||
# description: Window Order By All
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement error
|
||||
SELECT i, j, ROW_NUMBER() OVER (ORDER BY ALL) AS rn
|
||||
FROM (
|
||||
SELECT i ,j
|
||||
FROM generate_series(1, 5) s(i)
|
||||
CROSS JOIN generate_series(1, 2) t(j)
|
||||
) t;
|
||||
----
|
||||
Cannot ORDER BY ALL in a window expression
|
||||
|
||||
# We CAN order by column patterns
|
||||
query II
|
||||
SELECT
|
||||
rank() OVER (ORDER BY COLUMNS('^(.*)_score$') DESC) AS '\1_rank'
|
||||
FROM (
|
||||
SELECT
|
||||
range AS math_score,
|
||||
100-range as reading_score
|
||||
from range(65, 100, 5)
|
||||
);
|
||||
----
|
||||
7 1
|
||||
6 2
|
||||
5 3
|
||||
4 4
|
||||
3 5
|
||||
2 6
|
||||
1 7
|
||||
150
external/duckdb/test/sql/window/test_over_grouping.test_slow
vendored
Normal file
150
external/duckdb/test/sql/window/test_over_grouping.test_slow
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
# name: test/sql/window/test_over_grouping.test_slow
|
||||
# description: Grouping OVER clauses to reduce unnecessary sorting
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_parallelism
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output='__TEST_DIR__/test.json'
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_mode = detailed
|
||||
|
||||
statement ok
|
||||
create table image (
|
||||
id smallint primary key,
|
||||
width int not null,
|
||||
height integer not null
|
||||
);
|
||||
|
||||
statement ok
|
||||
insert into image (id, width, height) values (1, 500, 297);
|
||||
|
||||
set seed 0.8675309
|
||||
|
||||
statement ok
|
||||
create table pixel (
|
||||
image_id integer not null,
|
||||
x integer not null,
|
||||
y integer not null,
|
||||
red utinyint not null,
|
||||
green utinyint not null,
|
||||
blue utinyint not null
|
||||
);
|
||||
|
||||
statement ok
|
||||
insert into pixel
|
||||
select
|
||||
1 as image_id,
|
||||
r % 500 as x,
|
||||
r // 500 as y,
|
||||
random() * 255 as red,
|
||||
random() * 255 as green,
|
||||
random() * 255 as blue
|
||||
from (select range r from range(0, 297 * 500)) r;
|
||||
|
||||
query I
|
||||
select count(*) from pixel;
|
||||
----
|
||||
148500
|
||||
|
||||
statement ok
|
||||
create temp table delta1 as select range delta from range(-1,2);
|
||||
|
||||
statement ok
|
||||
create temp table delta2 as select x.delta as dx, y.delta as dy from delta1 x, delta1 y;
|
||||
|
||||
statement ok
|
||||
create sequence patchids;
|
||||
|
||||
statement ok
|
||||
create table patch AS
|
||||
SELECT p.* FROM (
|
||||
SELECT
|
||||
nextval('patchids') AS id,
|
||||
1 AS params_id,
|
||||
image_id,
|
||||
x + dx AS x_pos,
|
||||
y + dy AS y_pos,
|
||||
AVG(red) AS red_avg,
|
||||
AVG(green) AS green_avg,
|
||||
AVG(blue) AS blue_avg
|
||||
FROM pixel, delta2
|
||||
GROUP BY params_id, image_id, x_pos, y_pos
|
||||
) p, image i
|
||||
WHERE x_pos >= 1 AND x_pos < i.width - 1
|
||||
AND y_pos >= 1 AND y_pos < i.height - 1;
|
||||
|
||||
query I
|
||||
select count(*) from patch;
|
||||
----
|
||||
146910
|
||||
|
||||
statement ok
|
||||
create temp table channel (channel char(1));
|
||||
|
||||
statement ok
|
||||
insert into channel (channel) values ('R'), ('G'), ('B');
|
||||
|
||||
query I
|
||||
SELECT COUNT(*)
|
||||
FROM (
|
||||
SELECT
|
||||
patch_id,
|
||||
channel,
|
||||
coalesce(sqrt(grad_x * grad_x + grad_y * grad_y), 0.) AS grad_mag,
|
||||
coalesce(atan2(grad_y, grad_x), 0.) AS grad_angle
|
||||
FROM (
|
||||
SELECT
|
||||
patch_id,
|
||||
channel,
|
||||
(case channel when 'R' then r_x when 'G' then g_x else b_x end) as grad_x,
|
||||
(case channel when 'R' then r_y when 'G' then g_y else b_y end) as grad_y
|
||||
FROM (
|
||||
SELECT
|
||||
patch_id,
|
||||
(r_x_1::integer - r_x_0::integer) / 2.0 as r_x,
|
||||
(r_y_1::integer - r_y_0::integer) / 2.0 as r_y,
|
||||
(g_x_1::integer - g_x_0::integer) / 2.0 as g_x,
|
||||
(g_y_1::integer - g_y_0::integer) / 2.0 as g_y,
|
||||
(b_x_1::integer - b_x_0::integer) / 2.0 as b_x,
|
||||
(b_y_1::integer - b_y_0::integer) / 2.0 as b_y
|
||||
FROM (
|
||||
SELECT
|
||||
px.*,
|
||||
lead(red, 1) OVER (w) AS r_x_1,
|
||||
lag(red, 1) OVER (w) AS r_x_0,
|
||||
lead(green, 1) OVER (w) AS g_x_1,
|
||||
lag(green, 1) OVER (w) AS g_x_0,
|
||||
lead(blue, 1) OVER (w) AS b_x_1,
|
||||
lag(blue, 1) OVER (w) AS b_x_0,
|
||||
lead(red, 3) OVER (w) AS r_y_1,
|
||||
lag(red, 3) OVER (w) AS r_y_0,
|
||||
lead(green, 3) OVER (w) AS g_y_1,
|
||||
lag(green, 3) OVER (w) AS g_y_0,
|
||||
lead(blue, 3) OVER (w) AS b_y_1,
|
||||
lag(blue, 3) OVER (w) AS b_y_0
|
||||
FROM (
|
||||
SELECT
|
||||
p.id AS patch_id,
|
||||
px.*
|
||||
FROM (SELECT x + dx as x_pos, y + dy as y_pos, px.* FROM pixel px, delta2 d) px, patch p
|
||||
WHERE px.x_pos = p.x_pos AND px.y_pos = p.y_pos
|
||||
AND px.image_id = p.image_id
|
||||
AND p.params_id = 1
|
||||
) px
|
||||
WINDOW w AS (PARTITION BY patch_id ORDER BY y, x)
|
||||
) g
|
||||
WHERE x_pos = x AND y_pos = y
|
||||
) g, channel c
|
||||
) g
|
||||
) f;
|
||||
----
|
||||
440730
|
||||
49
external/duckdb/test/sql/window/test_parallel_window.test_slow
vendored
Normal file
49
external/duckdb/test/sql/window/test_parallel_window.test_slow
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# name: test/sql/window/test_parallel_window.test_slow
|
||||
# description: Hashing and parallel execution
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_parallelism
|
||||
|
||||
# Create a table large enough to fill the partitions
|
||||
statement ok
|
||||
create table integers as select range i from range(0, 1000000);
|
||||
|
||||
# Exact partition sizes
|
||||
query I
|
||||
select sum(s)from (
|
||||
select max(i) over(partition by i % 1024 order by i / 1024) s from integers
|
||||
) q
|
||||
----
|
||||
499999500000
|
||||
|
||||
# Slightly smaller partition sizes
|
||||
query I
|
||||
select sum(s)from (
|
||||
select max(i) over(partition by i % 1023 order by i / 1023) s from integers
|
||||
) q
|
||||
----
|
||||
499999500000
|
||||
|
||||
# Slightly larger partition sizes
|
||||
query I
|
||||
select sum(s)from (
|
||||
select max(i) over(partition by i % 1025 order by i / 1025) s from integers
|
||||
) q
|
||||
----
|
||||
499999500000
|
||||
|
||||
# Use strings as values to test copying dictionaries across segment boundaries
|
||||
statement ok
|
||||
create table strings as select i, i::varchar s, (i % 1023)::varchar ms, (i / 2023)::varchar ds from integers;
|
||||
|
||||
query II
|
||||
select min(len(w)), max(len(w))from (
|
||||
select max(s) over(partition by ms order by ds) w from strings
|
||||
) q
|
||||
----
|
||||
1
|
||||
6
|
||||
34
external/duckdb/test/sql/window/test_partition_flushing.test_slow
vendored
Normal file
34
external/duckdb/test/sql/window/test_partition_flushing.test_slow
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# name: test/sql/window/test_partition_flushing.test_slow
|
||||
# description: Test chunk flushing under multithreaded partitioning
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "data" ("Store" INTEGER, "Dept" INTEGER, "Date" DATE, "Weekly_Sales" DOUBLE, "IsHoliday" BOOLEAN);
|
||||
|
||||
statement ok
|
||||
insert into data select * from read_csv_auto('test/sql/window/walmart.csv.gz');
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
query II
|
||||
SELECT "Store", "Weekly_Sales"
|
||||
FROM (
|
||||
SELECT "Store", "Date", "Weekly_Sales", ROW_NUMBER() OVER (
|
||||
PARTITION BY "Store" ORDER BY "Date" DESC, "Dept"
|
||||
) r
|
||||
FROM data) w
|
||||
WHERE r = 1
|
||||
ORDER BY 1
|
||||
----
|
||||
1 27390.810000
|
||||
2 41615.240000
|
||||
3 11351.240000
|
||||
4 57046.290000
|
||||
5 12774.470000
|
||||
6 30579.350000
|
||||
7 10983.790000
|
||||
8 21737.930000
|
||||
9 20194.310000
|
||||
10 58409.830000
|
||||
11 23746.390000
|
||||
537
external/duckdb/test/sql/window/test_quantile_window.test
vendored
Normal file
537
external/duckdb/test/sql/window/test_quantile_window.test
vendored
Normal file
@@ -0,0 +1,537 @@
|
||||
# name: test/sql/window/test_quantile_window.test
|
||||
# description: Test MEDIAN and QUANTILE aggregates as window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_external
|
||||
|
||||
statement ok
|
||||
create table quantiles as select range r from range(10) union all values (NULL), (NULL), (NULL);
|
||||
|
||||
query III
|
||||
SELECT r % 2, r, median(r) over (partition by r % 2 order by r) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
0 0 0.0
|
||||
0 2 1.0
|
||||
0 4 2.0
|
||||
0 6 3.0
|
||||
0 8 4.0
|
||||
1 1 1.0
|
||||
1 3 2.0
|
||||
1 5 3.0
|
||||
1 7 4.0
|
||||
1 9 5.0
|
||||
|
||||
query II
|
||||
SELECT r, median(r) over (order by r rows between 1 preceding and 1 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
NULL 0.0
|
||||
0 0.5
|
||||
1 1.0
|
||||
2 2.0
|
||||
3 3.0
|
||||
4 4.0
|
||||
5 5.0
|
||||
6 6.0
|
||||
7 7.0
|
||||
8 8.0
|
||||
9 8.5
|
||||
|
||||
query II
|
||||
SELECT r, median(r) over (order by r rows between 1 preceding and 3 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL 0.0
|
||||
NULL 0.5
|
||||
NULL 1.0
|
||||
0 1.5
|
||||
1 2.0
|
||||
2 3.0
|
||||
3 4.0
|
||||
4 5.0
|
||||
5 6.0
|
||||
6 7.0
|
||||
7 7.5
|
||||
8 8.0
|
||||
9 8.5
|
||||
|
||||
query II
|
||||
SELECT r, quantile(r, 0.5) over (order by r rows between 1 preceding and 3 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL 0
|
||||
NULL 0
|
||||
NULL 1
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 7
|
||||
8 8
|
||||
9 8
|
||||
|
||||
#
|
||||
# VARCHAR
|
||||
#
|
||||
query III
|
||||
SELECT r % 2, r, median(r::VARCHAR) over (partition by r % 2 order by r) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
0 0 0
|
||||
0 2 0
|
||||
0 4 2
|
||||
0 6 2
|
||||
0 8 4
|
||||
1 1 1
|
||||
1 3 1
|
||||
1 5 3
|
||||
1 7 3
|
||||
1 9 5
|
||||
|
||||
|
||||
query II
|
||||
SELECT r, median(r::VARCHAR) over (order by r rows between 1 preceding and 1 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
NULL 0
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 8
|
||||
|
||||
query II
|
||||
SELECT r, quantile(r::VARCHAR, 0.5) over (order by r rows between 1 preceding and 3 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL 0
|
||||
NULL 0
|
||||
NULL 1
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 7
|
||||
8 8
|
||||
9 8
|
||||
|
||||
# Non-inlined
|
||||
query II
|
||||
SELECT r, median('prefix-' || r::VARCHAR || '-suffix') over (order by r rows between 1 preceding and 1 following) FROM quantiles ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
NULL prefix-0-suffix
|
||||
0 prefix-0-suffix
|
||||
1 prefix-1-suffix
|
||||
2 prefix-2-suffix
|
||||
3 prefix-3-suffix
|
||||
4 prefix-4-suffix
|
||||
5 prefix-5-suffix
|
||||
6 prefix-6-suffix
|
||||
7 prefix-7-suffix
|
||||
8 prefix-8-suffix
|
||||
9 prefix-8-suffix
|
||||
|
||||
# Scattered NULLs
|
||||
query IIII
|
||||
SELECT r % 3, r, n, median(n) over (partition by r % 3 order by r)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM quantiles) nulls
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL
|
||||
0 0 0 0.0
|
||||
0 3 NULL 0.0
|
||||
0 6 6 3.0
|
||||
0 9 NULL 3.0
|
||||
1 1 NULL NULL
|
||||
1 4 4 4.0
|
||||
1 7 NULL 4.0
|
||||
2 2 2 2.0
|
||||
2 5 NULL 2.0
|
||||
2 8 8 5.0
|
||||
|
||||
query III
|
||||
SELECT r, n, median(n) over (order by r rows between 1 preceding and 1 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM quantiles) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL NULL
|
||||
NULL NULL NULL
|
||||
NULL NULL 0.0
|
||||
0 0 0.0
|
||||
1 NULL 1.0
|
||||
2 2 2.0
|
||||
3 NULL 3.0
|
||||
4 4 4.0
|
||||
5 NULL 5.0
|
||||
6 6 6.0
|
||||
7 NULL 7.0
|
||||
8 8 8.0
|
||||
9 NULL 8.0
|
||||
|
||||
query III
|
||||
SELECT r, n, median(n) over (order by r rows between 1 preceding and 3 following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM quantiles) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 0.0
|
||||
NULL NULL 0.0
|
||||
NULL NULL 1.0
|
||||
0 0 1.0
|
||||
1 NULL 2.0
|
||||
2 2 3.0
|
||||
3 NULL 4.0
|
||||
4 4 5.0
|
||||
5 NULL 6.0
|
||||
6 6 7.0
|
||||
7 NULL 7.0
|
||||
8 8 8.0
|
||||
9 NULL 8.0
|
||||
|
||||
query III
|
||||
SELECT r, n, median(n) over (order by r rows between unbounded preceding and unbounded following)
|
||||
FROM (SELECT r, CASE r % 2 WHEN 0 THEN r ELSE NULL END AS n FROM quantiles) nulls
|
||||
ORDER BY 1
|
||||
----
|
||||
NULL NULL 4
|
||||
NULL NULL 4
|
||||
NULL NULL 4
|
||||
0 0 4
|
||||
1 NULL 4
|
||||
2 2 4
|
||||
3 NULL 4
|
||||
4 4 4
|
||||
5 NULL 4
|
||||
6 6 4
|
||||
7 NULL 4
|
||||
8 8 4
|
||||
9 NULL 4
|
||||
|
||||
#
|
||||
# Coverage tests
|
||||
#
|
||||
|
||||
# ReuseIndexes, backwards moving frame
|
||||
query II
|
||||
WITH t(i, p, f) AS (VALUES
|
||||
(0, 1, 1),
|
||||
(1, 1, 1),
|
||||
(2, 1, 1),
|
||||
(3, 3, 1),
|
||||
(4, 1, 1),
|
||||
(5, 3, 1)
|
||||
)
|
||||
SELECT i, MEDIAN(i) OVER (ORDER BY i ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 0.5
|
||||
1 1.0
|
||||
2 2.0
|
||||
3 2.0
|
||||
4 4.0
|
||||
5 3.5
|
||||
|
||||
# CanReplace
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 1),
|
||||
(1, 1, 1, 1),
|
||||
(2, 2, 1, 1),
|
||||
(3, 0, 1, 1),
|
||||
(4, 1, 1, 1),
|
||||
(5, 2, 1, 1)
|
||||
)
|
||||
SELECT r, MEDIAN(i) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 0.5
|
||||
1 1.0
|
||||
2 1.0
|
||||
3 1.0
|
||||
4 1.0
|
||||
5 1.5
|
||||
|
||||
# Moving discrete list
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 3, 1, 2),
|
||||
(4, 4, 1, 2),
|
||||
(5, 5, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_DISC(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [0, 1, 2]
|
||||
1 [0, 1, 2]
|
||||
2 [1, 2, 3]
|
||||
3 [2, 3, 4]
|
||||
4 [3, 4, 5]
|
||||
5 [4, 4, 5]
|
||||
|
||||
# Moving discrete list with NULLs
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, NULL, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 3, 1, 2),
|
||||
(4, 4, 1, 2),
|
||||
(5, 5, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_DISC(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [1, 1, 2]
|
||||
1 [1, 2, 3]
|
||||
2 [1, 2, 3]
|
||||
3 [2, 3, 4]
|
||||
4 [3, 4, 5]
|
||||
5 [4, 4, 5]
|
||||
|
||||
# Moving discrete list with all NULLs
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, NULL, 1, 2),
|
||||
(1, NULL, 1, 2),
|
||||
(2, NULL, 1, 2),
|
||||
(3, NULL, 1, 2),
|
||||
(4, NULL, 1, 2),
|
||||
(5, NULL, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_DISC(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 NULL
|
||||
1 NULL
|
||||
2 NULL
|
||||
3 NULL
|
||||
4 NULL
|
||||
5 NULL
|
||||
|
||||
# Moving continuous list
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 3, 1, 2),
|
||||
(4, 4, 1, 2),
|
||||
(5, 5, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_CONT(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [0.5, 1.0, 1.5]
|
||||
1 [0.75, 1.5, 2.25]
|
||||
2 [1.75, 2.5, 3.25]
|
||||
3 [2.75, 3.5, 4.25]
|
||||
4 [3.5, 4.0, 4.5]
|
||||
5 [4.25, 4.5, 4.75]
|
||||
|
||||
# Moving continuous list with replacement
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 0, 1, 2),
|
||||
(4, 1, 1, 2),
|
||||
(5, 2, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_CONT(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [0.5, 1.0, 1.5]
|
||||
1 [0.0, 0.5, 1.25]
|
||||
2 [0.75, 1.0, 1.25]
|
||||
3 [0.75, 1.5, 2.0]
|
||||
4 [0.5, 1.0, 1.5]
|
||||
5 [1.25, 1.5, 1.75]
|
||||
|
||||
#
|
||||
# Coverage
|
||||
#
|
||||
|
||||
# Discrete replace coverage
|
||||
query II
|
||||
SELECT r, quantile_disc(i, 0.5) OVER (ORDER BY r ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) q
|
||||
FROM (VALUES
|
||||
(0, 0),
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 0),
|
||||
(4, 1)
|
||||
) tbl(r, i)
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
0 0
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 0
|
||||
|
||||
# Continuous interpolated replace coverage
|
||||
query II
|
||||
SELECT r, quantile_cont(i, 0.5) OVER (ORDER BY r ROWS BETWEEN 2 PRECEDING AND 1 FOLLOWING) q
|
||||
FROM (VALUES
|
||||
(0, 0),
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, 0),
|
||||
(5, 1)
|
||||
) tbl(r, i)
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
0 0.5
|
||||
1 1.0
|
||||
2 1.5
|
||||
3 1.5
|
||||
4 1.5
|
||||
5 1.0
|
||||
|
||||
# NULL replace coverage
|
||||
query II
|
||||
SELECT r, quantile_cont(i, 0.5) OVER (ORDER BY r ROWS BETWEEN 2 PRECEDING AND 1 FOLLOWING) q
|
||||
FROM (VALUES
|
||||
(0, NULL),
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, NULL),
|
||||
(5, 1)
|
||||
) tbl(r, i)
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
0 1.0
|
||||
1 1.5
|
||||
2 2.0
|
||||
3 2.0
|
||||
4 2.0
|
||||
5 2.0
|
||||
|
||||
#
|
||||
# Compare implementations
|
||||
#
|
||||
|
||||
foreach windowmode "window" "combine" "separate"
|
||||
|
||||
statement ok
|
||||
PRAGMA debug_window_mode=${windowmode}
|
||||
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 1),
|
||||
(1, 1, 1, 1),
|
||||
(2, 2, 1, 1),
|
||||
(3, 0, 1, 1),
|
||||
(4, 1, 1, 1),
|
||||
(5, 2, 1, 1)
|
||||
)
|
||||
SELECT r, MEDIAN(i) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 0.5
|
||||
1 1.0
|
||||
2 1.0
|
||||
3 1.0
|
||||
4 1.0
|
||||
5 1.5
|
||||
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 1),
|
||||
(1, 1, 1, 1),
|
||||
(2, 2, 1, 1),
|
||||
(3, 0, 1, 1),
|
||||
(4, 1, 1, 1),
|
||||
(5, 2, 1, 1)
|
||||
)
|
||||
SELECT r, QUANTILE_DISC(i, 0.5) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 0
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, NULL, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 3, 1, 2),
|
||||
(4, 4, 1, 2),
|
||||
(5, 5, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_DISC(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [1, 1, 2]
|
||||
1 [1, 2, 3]
|
||||
2 [1, 2, 3]
|
||||
3 [2, 3, 4]
|
||||
4 [3, 4, 5]
|
||||
5 [4, 4, 5]
|
||||
|
||||
query II
|
||||
WITH t(r, i, p, f) AS (VALUES
|
||||
(0, 0, 1, 2),
|
||||
(1, 1, 1, 2),
|
||||
(2, 2, 1, 2),
|
||||
(3, 0, 1, 2),
|
||||
(4, 1, 1, 2),
|
||||
(5, 2, 1, 2)
|
||||
)
|
||||
SELECT r, QUANTILE_CONT(i, [0.25, 0.5, 0.75]) OVER (ORDER BY r ROWS BETWEEN p PRECEDING and f FOLLOWING)
|
||||
FROM t
|
||||
ORDER BY 1
|
||||
----
|
||||
0 [0.5, 1.0, 1.5]
|
||||
1 [0.0, 0.5, 1.25]
|
||||
2 [0.75, 1.0, 1.25]
|
||||
3 [0.75, 1.5, 2.0]
|
||||
4 [0.5, 1.0, 1.5]
|
||||
5 [1.25, 1.5, 1.75]
|
||||
|
||||
endloop
|
||||
80
external/duckdb/test/sql/window/test_quantile_window.test_coverage
vendored
Normal file
80
external/duckdb/test/sql/window/test_quantile_window.test_coverage
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# name: test/sql/window/test_quantile_window.test_coverage
|
||||
# description: Moving QUANTILE coverage, fixed or variable 100 element frame for MEDIAN, IQR, and MAD
|
||||
# group: [window]
|
||||
|
||||
# Common table
|
||||
statement ok
|
||||
create table rank100 as
|
||||
select b % 100 as a, b from range(10000000) tbl(b)
|
||||
|
||||
# window_median_fixed_100
|
||||
query I
|
||||
select sum(m)
|
||||
from (
|
||||
select median(a) over (
|
||||
order by b asc
|
||||
rows between 100 preceding and current row) as m
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
494997500
|
||||
|
||||
# window_median_variable_100
|
||||
query I
|
||||
select sum(m)
|
||||
from (
|
||||
select median(a) over (
|
||||
order by b asc
|
||||
rows between mod(b * 47, 521) preceding and 100 - mod(b * 47, 521) following) as m
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
494989867
|
||||
|
||||
# window_iqr_fixed_100
|
||||
query II
|
||||
select min(iqr), max(iqr)
|
||||
from (
|
||||
select quantile_cont(a, [0.25, 0.5, 0.75]) over (
|
||||
order by b asc
|
||||
rows between 100 preceding and current row) as iqr
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
[0.0, 0.0, 0.0] [25.0, 50.0, 75.0]
|
||||
|
||||
# window_iqr_variable_100
|
||||
query II
|
||||
select min(iqr), max(iqr)
|
||||
from (
|
||||
select quantile_cont(a, [0.25, 0.5, 0.75]) over (
|
||||
order by b asc
|
||||
rows between mod(b * 47, 521) preceding and 100 - mod(b * 47, 521) following) as iqr
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
[0.0, 0.0, 0.0] [76.5, 84.0, 91.5]
|
||||
|
||||
# window_mad_fixed_100
|
||||
query I
|
||||
select sum(m)
|
||||
from (
|
||||
select mad(a) over (
|
||||
order by b asc
|
||||
rows between 100 preceding and current row) as m
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
249998762.5
|
||||
|
||||
#
|
||||
query I
|
||||
select sum(m)
|
||||
from (
|
||||
select mad(a) over (
|
||||
order by b asc
|
||||
rows between mod(b * 47, 521) preceding and 100 - mod(b * 47, 521) following) as m
|
||||
from rank100
|
||||
) q;
|
||||
----
|
||||
249994596.000000
|
||||
50
external/duckdb/test/sql/window/test_range_optimisation.test
vendored
Normal file
50
external/duckdb/test/sql/window/test_range_optimisation.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/sql/window/test_range_optimisation.test
|
||||
# description: Range search optimisation stress tests
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE rides (
|
||||
id INTEGER,
|
||||
requested_date DATE,
|
||||
city VARCHAR,
|
||||
wait_time INTEGER
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO rides VALUES
|
||||
(0, '2023-01-05', 'San Francisco', 2925),
|
||||
(1, '2023-01-03', 'San Francisco', 755),
|
||||
(2, '2023-01-03', 'San Francisco', 2880),
|
||||
(3, '2023-01-05', 'San Francisco', 1502),
|
||||
(4, '2023-01-03', 'San Francisco', 2900),
|
||||
(5, '2023-01-01', 'San Francisco', 1210),
|
||||
(6, '2023-01-04', 'San Francisco', 200),
|
||||
(7, '2023-01-02', 'San Francisco', 980),
|
||||
(8, '2023-01-02', 'San Francisco', 430),
|
||||
(9, '2023-01-05', 'San Francisco', 2999),
|
||||
(10, '2023-01-01', 'San Francisco', 856),
|
||||
(11, '2023-01-02', 'San Francisco', 490),
|
||||
(12, '2023-01-02', 'San Francisco', 720),
|
||||
|
||||
query IIIII
|
||||
SELECT "id", "requested_date", "city", "wait_time", min("wait_time") OVER win_3d
|
||||
FROM rides
|
||||
WINDOW win_3d AS (
|
||||
PARTITION BY "city"
|
||||
ORDER BY requested_date ASC
|
||||
RANGE BETWEEN INTERVAL 3 DAYS PRECEDING AND INTERVAL 1 DAYS PRECEDING)
|
||||
ORDER BY "requested_date", "city", "id"
|
||||
----
|
||||
5 2023-01-01 San Francisco 1210 NULL
|
||||
10 2023-01-01 San Francisco 856 NULL
|
||||
7 2023-01-02 San Francisco 980 856
|
||||
8 2023-01-02 San Francisco 430 856
|
||||
11 2023-01-02 San Francisco 490 856
|
||||
12 2023-01-02 San Francisco 720 856
|
||||
1 2023-01-03 San Francisco 755 430
|
||||
2 2023-01-03 San Francisco 2880 430
|
||||
4 2023-01-03 San Francisco 2900 430
|
||||
6 2023-01-04 San Francisco 200 430
|
||||
0 2023-01-05 San Francisco 2925 200
|
||||
3 2023-01-05 San Francisco 1502 200
|
||||
9 2023-01-05 San Francisco 2999 200
|
||||
50
external/duckdb/test/sql/window/test_rank.test
vendored
Normal file
50
external/duckdb/test/sql/window/test_rank.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/sql/window/test_rank.test
|
||||
# description: Test RANK state computations
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Multiple chunks, single partition
|
||||
query IIIII
|
||||
WITH t AS (
|
||||
SELECT i, RANK() OVER (ORDER BY i % 50) AS d
|
||||
FROM range(3000) tbl(i)
|
||||
), w AS (
|
||||
SELECT d, COUNT(*) as c
|
||||
FROM t
|
||||
GROUP BY ALL
|
||||
)
|
||||
SELECT COUNT(*), MIN(d), MAX(d), MIN(c), MAX(c)
|
||||
FROM w
|
||||
----
|
||||
50 1 2941 60 60
|
||||
|
||||
# Multiple chunks, multiple partitions
|
||||
query IIIII
|
||||
WITH t AS (
|
||||
SELECT i, RANK() OVER (PARTITION BY i // 3000 ORDER BY i % 50) AS d
|
||||
FROM range(9000) tbl(i)
|
||||
), w AS (
|
||||
SELECT d, COUNT(*) as c
|
||||
FROM t
|
||||
GROUP BY ALL
|
||||
)
|
||||
SELECT COUNT(*), MIN(d), MAX(d), MIN(c), MAX(c)
|
||||
FROM w
|
||||
----
|
||||
50 1 2941 180 180
|
||||
|
||||
# Different null ordering
|
||||
query III
|
||||
SELECT
|
||||
*,
|
||||
RANK() OVER (ORDER BY x NULLS FIRST) rank_nulls_first,
|
||||
RANK() OVER (ORDER BY x NULLS LAST) rank_nulls_last,
|
||||
FROM VALUES (1), (1), (1), (NULL) as issue8315(x)
|
||||
ORDER BY x
|
||||
----
|
||||
1.0 2 1
|
||||
1.0 2 1
|
||||
1.0 2 1
|
||||
NULL 1 4
|
||||
77
external/duckdb/test/sql/window/test_rank_orderby.test
vendored
Normal file
77
external/duckdb/test/sql/window/test_rank_orderby.test
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# name: test/sql/window/test_rank_orderby.test
|
||||
# description: Test argument ordering for RANK and PERCENT_RANK
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
i,
|
||||
(i * 29) % 11 AS outside,
|
||||
rank(ORDER BY (i // 2) DESC) OVER w,
|
||||
percent_rank(ORDER BY (i // 2) DESC) OVER w,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY (i * 29) % 11
|
||||
)
|
||||
ORDER BY 2
|
||||
----
|
||||
0 0 1 0.0
|
||||
8 1 1 0.0
|
||||
5 2 2 0.5
|
||||
2 3 3 0.6666666666666666
|
||||
7 5 2 0.25
|
||||
4 6 3 0.4
|
||||
1 7 6 0.8333333333333334
|
||||
9 8 1 0.0
|
||||
6 9 3 0.25
|
||||
3 10 7 0.6666666666666666
|
||||
|
||||
# Test parallel token construction (uses 4 threads)
|
||||
query IIIII
|
||||
WITH ranked AS (
|
||||
SELECT
|
||||
i,
|
||||
i // 100 AS p,
|
||||
i % 50 AS o,
|
||||
100 - 2 * (i % 50) - 1 AS expected,
|
||||
rank(ORDER BY i % 50 DESC) OVER w AS actual,
|
||||
FROM range(100_000) tbl(i)
|
||||
WINDOW w AS (
|
||||
PARTITION BY i // 100
|
||||
ORDER BY i
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
)
|
||||
)
|
||||
SELECT *
|
||||
FROM ranked
|
||||
WHERE expected <> actual
|
||||
ORDER BY p, o DESC
|
||||
LIMIT 20
|
||||
----
|
||||
|
||||
# Test duplicate ORDER BY optimisation
|
||||
query IIII
|
||||
SELECT
|
||||
i,
|
||||
i // 2 AS outside,
|
||||
rank(ORDER BY i // 2) OVER w,
|
||||
percent_rank(ORDER BY i // 2) OVER w,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
)
|
||||
ORDER BY 1
|
||||
----
|
||||
0 0 1 0.0
|
||||
1 0 1 0.0
|
||||
2 1 3 0.4
|
||||
3 1 3 0.3333333333333333
|
||||
4 2 4 0.5
|
||||
5 2 3 0.3333333333333333
|
||||
6 3 4 0.5
|
||||
7 3 3 0.4
|
||||
8 4 4 0.75
|
||||
9 4 3 0.6666666666666666
|
||||
29
external/duckdb/test/sql/window/test_rownumber_orderby.test
vendored
Normal file
29
external/duckdb/test/sql/window/test_rownumber_orderby.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/sql/window/test_rownumber_orderby.test
|
||||
# description: Test argument ordering for ROW_NUMBER and NTILE
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
i,
|
||||
(i * 29) % 11 AS outside,
|
||||
row_number(ORDER BY (i // 2) DESC) OVER w,
|
||||
ntile(4 ORDER BY (i // 2) DESC) OVER w,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY (i * 29) % 11
|
||||
)
|
||||
ORDER BY 2
|
||||
----
|
||||
0 0 1 1
|
||||
8 1 1 1
|
||||
5 2 2 2
|
||||
2 3 3 3
|
||||
7 5 2 1
|
||||
4 6 4 2
|
||||
1 7 7 4
|
||||
9 8 2 1
|
||||
6 9 4 2
|
||||
3 10 8 3
|
||||
44
external/duckdb/test/sql/window/test_scalar_window.test
vendored
Normal file
44
external/duckdb/test/sql/window/test_scalar_window.test
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# name: test/sql/window/test_scalar_window.test
|
||||
# description: Most scalar window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# test scalar window functions
|
||||
query I
|
||||
SELECT row_number() OVER ()
|
||||
----
|
||||
1
|
||||
|
||||
query R
|
||||
SELECT avg(42) OVER ()
|
||||
----
|
||||
42.000000
|
||||
|
||||
# window on non-aggregate function
|
||||
statement error
|
||||
SELECT concat() OVER ()
|
||||
----
|
||||
<REGEX>:.*Catalog Error.*concat is not an aggregate function.*
|
||||
|
||||
statement error
|
||||
SELECT nonexistingfunction() OVER ()
|
||||
----
|
||||
<REGEX>:.*Catalog Error.*nonexistingfunction does not exist.*
|
||||
|
||||
# nested window functions are not allowed
|
||||
statement error
|
||||
SELECT avg(row_number() over ()) over ()
|
||||
----
|
||||
<REGEX>:.*Binder Error.*window function calls cannot be nested.*
|
||||
|
||||
statement error
|
||||
SELECT avg(42) over (partition by row_number() over ())
|
||||
----
|
||||
<REGEX>:.*Parser Error.*window functions are not allowed.*
|
||||
|
||||
statement error
|
||||
SELECT avg(42) over (order by row_number() over ())
|
||||
----
|
||||
<REGEX>:.*Parser Error.*window functions are not allowed.*
|
||||
12
external/duckdb/test/sql/window/test_split_partition_heap.test
vendored
Normal file
12
external/duckdb/test/sql/window/test_split_partition_heap.test
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# name: test/sql/window/test_split_partition_heap.test
|
||||
# description: Validate AlignHeapBlocks whith 2 heap : 1 data
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table partsupp as select uuid()::varchar as c5 from range(8000);
|
||||
|
||||
statement ok
|
||||
SELECT (ntile(5002) OVER (ROWS BETWEEN CURRENT ROW AND CURRENT ROW) >= 0), c5 FROM partsupp;
|
||||
251
external/duckdb/test/sql/window/test_streaming_lead_lag.test
vendored
Normal file
251
external/duckdb/test/sql/window/test_streaming_lead_lag.test
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
# name: test/sql/window/test_streaming_lead_lag.test
|
||||
# description: Streaming window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA explain_output = PHYSICAL_ONLY;
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 NULL
|
||||
1 0
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 4
|
||||
6 5
|
||||
7 6
|
||||
8 7
|
||||
9 8
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LAG(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 NULL
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LEAD(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 NULL
|
||||
1 0
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 4
|
||||
6 5
|
||||
7 6
|
||||
8 7
|
||||
9 8
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LEAD(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 NULL
|
||||
|
||||
# Test shift down
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(3000) tbl(i)
|
||||
WHERE i % 2 = 0
|
||||
QUALIFY i1 <> i - 2
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(3000) tbl(i)
|
||||
WHERE i % 2 = 0
|
||||
QUALIFY i1 <> i - 2
|
||||
----
|
||||
|
||||
# Test constant default value
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, 1, 50) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LAG(i, 1, 50) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 50
|
||||
1 0
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 4
|
||||
6 5
|
||||
7 6
|
||||
8 7
|
||||
9 8
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 1, 50) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LEAD(i, 1, 50) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 50
|
||||
|
||||
# Test sparse leads
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 2) OVER() AS i1
|
||||
FROM range(3000) tbl(i)
|
||||
WHERE i % 2048 = 0
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LEAD(i, 2) OVER() AS i1
|
||||
FROM range(3000) tbl(i)
|
||||
WHERE i % 2048 = 0
|
||||
----
|
||||
0 NULL
|
||||
2048 NULL
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 2) OVER() AS i1
|
||||
FROM range(5000) tbl(i)
|
||||
WHERE i % 2048 = 0
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LEAD(i, 2) OVER() AS i1
|
||||
FROM range(5000) tbl(i)
|
||||
WHERE i % 2048 = 0
|
||||
----
|
||||
0 4096
|
||||
2048 NULL
|
||||
4096 NULL
|
||||
|
||||
# Test long deltas
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, 3000) OVER() AS i1
|
||||
FROM range(5000) tbl(i);
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 3000) OVER() AS i1
|
||||
FROM range(5000) tbl(i);
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
# Test multiple, unequal LEADs
|
||||
query III
|
||||
SELECT i, LEAD(i, 1) OVER(), LEAD(i, 2) OVER()
|
||||
FROM range(10) tbl(i)
|
||||
----
|
||||
0 1 2
|
||||
1 2 3
|
||||
2 3 4
|
||||
3 4 5
|
||||
4 5 6
|
||||
5 6 7
|
||||
6 7 8
|
||||
7 8 9
|
||||
8 9 NULL
|
||||
9 NULL NULL
|
||||
|
||||
# Test incomplete buffering
|
||||
query II
|
||||
select * from (
|
||||
select
|
||||
id,
|
||||
lead(id, 2047, -1) over() l
|
||||
from range(6144) tbl(id)
|
||||
where id != 1
|
||||
and id != 2
|
||||
and id != 2500
|
||||
and id != 2501
|
||||
and id != 2502
|
||||
)
|
||||
where id >= 2040 and id <= 2050;
|
||||
----
|
||||
2040 4090
|
||||
2041 4091
|
||||
2042 4092
|
||||
2043 4093
|
||||
2044 4094
|
||||
2045 4095
|
||||
2046 4096
|
||||
2047 4097
|
||||
2048 4098
|
||||
2049 4099
|
||||
2050 4100
|
||||
99
external/duckdb/test/sql/window/test_streaming_lead_lag.test_slow
vendored
Normal file
99
external/duckdb/test/sql/window/test_streaming_lead_lag.test_slow
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
# name: test/sql/window/test_streaming_lead_lag.test_slow
|
||||
# description: Streaming window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA explain_output = PHYSICAL_ONLY;
|
||||
|
||||
# Test all data types
|
||||
query II
|
||||
EXPLAIN
|
||||
SELECT
|
||||
lag(COLUMNS(*), 1) OVER (),
|
||||
lead(COLUMNS(*), -1) OVER()
|
||||
FROM test_all_types()
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
|
||||
SELECT
|
||||
lag(COLUMNS(*), 1) OVER (),
|
||||
lead(COLUMNS(*), -1) OVER()
|
||||
FROM test_all_types()
|
||||
----
|
||||
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
0 -128 -32768 -2147483648 -9223372036854775808 -170141183460469231731687303715884105728 0 0 0 0 0 -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5877642-06-25 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 1677-09-22 00:00:00 00:00:00+15:59:59 290309-12-22 (BC) 00:00:00+00 -3.4028235e+38 -1.7976931348623157e+308 -999.9 -99999.9999 -999999999999.999999 -9999999999999999999999999999.9999999999 00000000-0000-0000-0000-000000000000 00:00:00 🦆🦆🦆🦆🦆🦆 thisisalongblob\x00withnullbytes 0010001001011100010101011010111 DUCK_DUCK_ENUM enum_0 enum_0 [] [] [] [] [] [] [] {'a': NULL, 'b': NULL} {'a': NULL, 'b': NULL} [] {} Frank [NULL, 2, 3] [a, NULL, c] [[NULL, 2, 3], NULL, [NULL, 2, 3]] [[a, NULL, c], NULL, [a, NULL, c]] [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}] {'a': [NULL, 2, 3], 'b': [a, NULL, c]} [[], [42, 999, NULL, NULL, -42], []] [[NULL, 2, 3], [4, 5, 6], [NULL, 2, 3]] 0 -128 -32768 -2147483648 -9223372036854775808 -170141183460469231731687303715884105728 0 0 0 0 0 -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5877642-06-25 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 290309-12-22 (BC) 00:00:00 1677-09-22 00:00:00 00:00:00+15:59:59 290309-12-22 (BC) 00:00:00+00 -3.4028235e+38 -1.7976931348623157e+308 -999.9 -99999.9999 -999999999999.999999 -9999999999999999999999999999.9999999999 00000000-0000-0000-0000-000000000000 00:00:00 🦆🦆🦆🦆🦆🦆 thisisalongblob\x00withnullbytes 0010001001011100010101011010111 DUCK_DUCK_ENUM enum_0 enum_0 [] [] [] [] [] [] [] {'a': NULL, 'b': NULL} {'a': NULL, 'b': NULL} [] {} Frank [NULL, 2, 3] [a, NULL, c] [[NULL, 2, 3], NULL, [NULL, 2, 3]] [[a, NULL, c], NULL, [a, NULL, c]] [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}] {'a': [NULL, 2, 3], 'b': [a, NULL, c]} [[], [42, 999, NULL, NULL, -42], []] [[NULL, 2, 3], [4, 5, 6], [NULL, 2, 3]]
|
||||
1 127 32767 2147483647 9223372036854775807 170141183460469231731687303715884105727 340282366920938463463374607431768211455 255 65535 4294967295 18446744073709551615 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5881580-07-10 24:00:00 294247-01-10 04:00:54.775806 294247-01-10 04:00:54 294247-01-10 04:00:54.775 2262-04-11 23:47:16.854775806 24:00:00-15:59:59 294247-01-10 04:00:54.775806+00 3.4028235e+38 1.7976931348623157e+308 999.9 99999.9999 999999999999.999999 9999999999999999999999999999.9999999999 ffffffff-ffff-ffff-ffff-ffffffffffff 83 years 3 months 999 days 00:16:39.999999 goo\0se \x00\x00\x00a 10101 GOOSE enum_299 enum_69999 [42, 999, NULL, NULL, -42] [42.0, nan, inf, -inf, NULL, -42.0] [1970-01-01, infinity, -infinity, NULL, 2022-05-12] ['1970-01-01 00:00:00', infinity, -infinity, NULL, '2022-05-12 16:23:45'] ['1970-01-01 00:00:00+00', infinity, -infinity, NULL, '2022-05-12 23:23:45+00'] [🦆🦆🦆🦆🦆🦆, goose, NULL, ''] [[], [42, 999, NULL, NULL, -42], NULL, [], [42, 999, NULL, NULL, -42]] {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆} {'a': [42, 999, NULL, NULL, -42], 'b': [🦆🦆🦆🦆🦆🦆, goose, NULL, '']} [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, NULL] {key1=🦆🦆🦆🦆🦆🦆, key2=goose} 5 [4, 5, 6] [d, e, f] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] [[d, e, f], [a, NULL, c], [d, e, f]] [{'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}] {'a': [4, 5, 6], 'b': [d, e, f]} [[42, 999, NULL, NULL, -42], [], [42, 999, NULL, NULL, -42]] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] 1 127 32767 2147483647 9223372036854775807 170141183460469231731687303715884105727 340282366920938463463374607431768211455 255 65535 4294967295 18446744073709551615 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5881580-07-10 24:00:00 294247-01-10 04:00:54.775806 294247-01-10 04:00:54 294247-01-10 04:00:54.775 2262-04-11 23:47:16.854775806 24:00:00-15:59:59 294247-01-10 04:00:54.775806+00 3.4028235e+38 1.7976931348623157e+308 999.9 99999.9999 999999999999.999999 9999999999999999999999999999.9999999999 ffffffff-ffff-ffff-ffff-ffffffffffff 83 years 3 months 999 days 00:16:39.999999 goo\0se \x00\x00\x00a 10101 GOOSE enum_299 enum_69999 [42, 999, NULL, NULL, -42] [42.0, nan, inf, -inf, NULL, -42.0] [1970-01-01, infinity, -infinity, NULL, 2022-05-12] ['1970-01-01 00:00:00', infinity, -infinity, NULL, '2022-05-12 16:23:45'] ['1970-01-01 00:00:00+00', infinity, -infinity, NULL, '2022-05-12 23:23:45+00'] [🦆🦆🦆🦆🦆🦆, goose, NULL, ''] [[], [42, 999, NULL, NULL, -42], NULL, [], [42, 999, NULL, NULL, -42]] {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆} {'a': [42, 999, NULL, NULL, -42], 'b': [🦆🦆🦆🦆🦆🦆, goose, NULL, '']} [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, NULL] {key1=🦆🦆🦆🦆🦆🦆, key2=goose} 5 [4, 5, 6] [d, e, f] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] [[d, e, f], [a, NULL, c], [d, e, f]] [{'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}] {'a': [4, 5, 6], 'b': [d, e, f]} [[42, 999, NULL, NULL, -42], [], [42, 999, NULL, NULL, -42]] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]]
|
||||
|
||||
|
||||
query II
|
||||
EXPLAIN
|
||||
SELECT
|
||||
lag(COLUMNS(*), -1) OVER(),
|
||||
lead(COLUMNS(*), 1) OVER()
|
||||
FROM test_all_types()
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
|
||||
SELECT
|
||||
lag(COLUMNS(*), -1) OVER(),
|
||||
lead(COLUMNS(*), 1) OVER()
|
||||
FROM test_all_types()
|
||||
----
|
||||
1 127 32767 2147483647 9223372036854775807 170141183460469231731687303715884105727 340282366920938463463374607431768211455 255 65535 4294967295 18446744073709551615 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5881580-07-10 24:00:00 294247-01-10 04:00:54.775806 294247-01-10 04:00:54 294247-01-10 04:00:54.775 2262-04-11 23:47:16.854775806 24:00:00-15:59:59 294247-01-10 04:00:54.775806+00 3.4028235e+38 1.7976931348623157e+308 999.9 99999.9999 999999999999.999999 9999999999999999999999999999.9999999999 ffffffff-ffff-ffff-ffff-ffffffffffff 83 years 3 months 999 days 00:16:39.999999 goo\0se \x00\x00\x00a 10101 GOOSE enum_299 enum_69999 [42, 999, NULL, NULL, -42] [42.0, nan, inf, -inf, NULL, -42.0] [1970-01-01, infinity, -infinity, NULL, 2022-05-12] ['1970-01-01 00:00:00', infinity, -infinity, NULL, '2022-05-12 16:23:45'] ['1970-01-01 00:00:00+00', infinity, -infinity, NULL, '2022-05-12 23:23:45+00'] [🦆🦆🦆🦆🦆🦆, goose, NULL, ''] [[], [42, 999, NULL, NULL, -42], NULL, [], [42, 999, NULL, NULL, -42]] {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆} {'a': [42, 999, NULL, NULL, -42], 'b': [🦆🦆🦆🦆🦆🦆, goose, NULL, '']} [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, NULL] {key1=🦆🦆🦆🦆🦆🦆, key2=goose} 5 [4, 5, 6] [d, e, f] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] [[d, e, f], [a, NULL, c], [d, e, f]] [{'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}] {'a': [4, 5, 6], 'b': [d, e, f]} [[42, 999, NULL, NULL, -42], [], [42, 999, NULL, NULL, -42]] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] 1 127 32767 2147483647 9223372036854775807 170141183460469231731687303715884105727 340282366920938463463374607431768211455 255 65535 4294967295 18446744073709551615 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368 5881580-07-10 24:00:00 294247-01-10 04:00:54.775806 294247-01-10 04:00:54 294247-01-10 04:00:54.775 2262-04-11 23:47:16.854775806 24:00:00-15:59:59 294247-01-10 04:00:54.775806+00 3.4028235e+38 1.7976931348623157e+308 999.9 99999.9999 999999999999.999999 9999999999999999999999999999.9999999999 ffffffff-ffff-ffff-ffff-ffffffffffff 83 years 3 months 999 days 00:16:39.999999 goo\0se \x00\x00\x00a 10101 GOOSE enum_299 enum_69999 [42, 999, NULL, NULL, -42] [42.0, nan, inf, -inf, NULL, -42.0] [1970-01-01, infinity, -infinity, NULL, 2022-05-12] ['1970-01-01 00:00:00', infinity, -infinity, NULL, '2022-05-12 16:23:45'] ['1970-01-01 00:00:00+00', infinity, -infinity, NULL, '2022-05-12 23:23:45+00'] [🦆🦆🦆🦆🦆🦆, goose, NULL, ''] [[], [42, 999, NULL, NULL, -42], NULL, [], [42, 999, NULL, NULL, -42]] {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆} {'a': [42, 999, NULL, NULL, -42], 'b': [🦆🦆🦆🦆🦆🦆, goose, NULL, '']} [{'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, NULL] {key1=🦆🦆🦆🦆🦆🦆, key2=goose} 5 [4, 5, 6] [d, e, f] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]] [[d, e, f], [a, NULL, c], [d, e, f]] [{'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}, {'a': NULL, 'b': NULL}, {'a': 42, 'b': 🦆🦆🦆🦆🦆🦆}] {'a': [4, 5, 6], 'b': [d, e, f]} [[42, 999, NULL, NULL, -42], [], [42, 999, NULL, NULL, -42]] [[4, 5, 6], [NULL, 2, 3], [4, 5, 6]]
|
||||
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
|
||||
|
||||
# Test round trip for all types
|
||||
statement ok
|
||||
create table all_types as from test_all_types()
|
||||
|
||||
foreach col <all_types_columns>
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT lead(lag, -1) over () IS NOT DISTINCT FROM lag(lead, 1) over ()
|
||||
FROM (
|
||||
SELECT lag("${col}", 1) OVER () AS lag, lead("${col}", -1) OVER () AS lead
|
||||
FROM test_all_types()
|
||||
)
|
||||
QUALIFY row_number() over ()==2;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query I
|
||||
SELECT lead(lag, -1) over () IS NOT DISTINCT FROM lag(lead, 1) over ()
|
||||
FROM (
|
||||
SELECT lag("${col}", 1) OVER () AS lag, lead("${col}", -1) OVER () AS lead
|
||||
FROM test_all_types()
|
||||
)
|
||||
QUALIFY row_number() over ()==2;
|
||||
----
|
||||
true
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT lead(lag, 1) over () IS NOT DISTINCT FROM lag(lead, -1) over ()
|
||||
FROM (
|
||||
SELECT lag("${col}", -1) OVER () AS lag, lead("${col}", 1) OVER () AS lead
|
||||
FROM test_all_types()
|
||||
)
|
||||
QUALIFY row_number() over ()==2;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query I
|
||||
SELECT lead(lag, 1) over () IS NOT DISTINCT FROM lag(lead, -1) over ()
|
||||
FROM (
|
||||
SELECT lag("${col}", -1) OVER () AS lag, lead("${col}", 1) OVER () AS lead
|
||||
FROM test_all_types()
|
||||
)
|
||||
QUALIFY row_number() over ()==2;
|
||||
----
|
||||
true
|
||||
|
||||
endloop
|
||||
448
external/duckdb/test/sql/window/test_streaming_window.test
vendored
Normal file
448
external/duckdb/test/sql/window/test_streaming_window.test
vendored
Normal file
@@ -0,0 +1,448 @@
|
||||
# name: test/sql/window/test_streaming_window.test
|
||||
# description: Streaming window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA explain_output = PHYSICAL_ONLY;
|
||||
|
||||
statement ok
|
||||
create table integers (i int, j int)
|
||||
|
||||
statement ok
|
||||
insert into integers values (2, 2), (2, 1), (1, 2), (1, NULL)
|
||||
|
||||
query TT
|
||||
explain select first_value(i IGNORE NULLS) over () from integers
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
# Unsupported aggregates
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, COUNT(*) OVER() FROM integers;
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, SUM(i) OVER() FROM integers;
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT j, COUNT(j) FILTER(WHERE i = 2) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT j, COUNT(*) FILTER(WHERE i = 2) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT j, SUM(j) FILTER(WHERE i = 2) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
# Test each of the streaming window functions
|
||||
query TT
|
||||
explain select row_number() over (), i, j from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TTT
|
||||
select row_number() over (), i, j from integers
|
||||
----
|
||||
1 2 2
|
||||
2 2 1
|
||||
3 1 2
|
||||
4 1 NULL
|
||||
|
||||
query TT
|
||||
explain select rank() over (), i, j from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TTT
|
||||
select rank() over (), i, j from integers
|
||||
----
|
||||
1 2 2
|
||||
1 2 1
|
||||
1 1 2
|
||||
1 1 NULL
|
||||
|
||||
query TT
|
||||
explain select dense_rank() over (), i, j from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TTT
|
||||
select dense_rank() over (), i, j from integers
|
||||
----
|
||||
1 2 2
|
||||
1 2 1
|
||||
1 1 2
|
||||
1 1 NULL
|
||||
|
||||
query TT
|
||||
explain select percent_rank() over (), i, j from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TTT
|
||||
select percent_rank() over (), i, j from integers
|
||||
----
|
||||
0.0 2 2
|
||||
0.0 2 1
|
||||
0.0 1 2
|
||||
0.0 1 NULL
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LAG(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 NULL
|
||||
1 0
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 4
|
||||
6 5
|
||||
7 6
|
||||
8 7
|
||||
9 8
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LAG(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LAG(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 NULL
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, LEAD(i, -1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 NULL
|
||||
1 0
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 4
|
||||
6 5
|
||||
7 6
|
||||
8 7
|
||||
9 8
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, LEAD(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
SELECT i, LEAD(i, 1) OVER() AS i1
|
||||
FROM range(10) tbl(i);
|
||||
----
|
||||
0 1
|
||||
1 2
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
5 6
|
||||
6 7
|
||||
7 8
|
||||
8 9
|
||||
9 NULL
|
||||
|
||||
# Test running aggregates
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, COUNT(*) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, COUNT(*) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
2 1
|
||||
2 2
|
||||
1 3
|
||||
1 4
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, COUNT(*) FILTER(WHERE i = 2) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, COUNT(*) FILTER(WHERE i = 2) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
2 1
|
||||
2 2
|
||||
1 2
|
||||
1 2
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT j, COUNT(j) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT j, COUNT(j) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
2 1
|
||||
1 2
|
||||
2 3
|
||||
NULL 3
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, SUM(i) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT i, SUM(i) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i, SUM(i) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM integers;
|
||||
----
|
||||
2 2
|
||||
2 4
|
||||
1 5
|
||||
1 6
|
||||
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT SUM(s) FROM (
|
||||
SELECT SUM(i) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) s
|
||||
FROM range(5000) tbl(i)
|
||||
);
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query I
|
||||
SELECT SUM(s) FROM (
|
||||
SELECT SUM(i) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) s
|
||||
FROM range(5000) tbl(i)
|
||||
);
|
||||
----
|
||||
20833332500
|
||||
|
||||
# Some combinations of compatible window functions
|
||||
query TT
|
||||
explain select i, j, first_value(i) over (), first_value(j) over () from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query TTTT
|
||||
select i, j, first_value(i) over (), first_value(j) over () from integers
|
||||
----
|
||||
2 2 2 2
|
||||
2 1 2 2
|
||||
1 2 2 2
|
||||
1 NULL 2 2
|
||||
|
||||
query TTT
|
||||
select row_number() over (), first_value(i) over (), first_value(j) over () from integers
|
||||
----
|
||||
1 2 2
|
||||
2 2 2
|
||||
3 2 2
|
||||
4 2 2
|
||||
|
||||
query TT
|
||||
select row_number() over (), row_number() over () from integers
|
||||
----
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
|
||||
# Ignore nulls is not supported for streaming windows
|
||||
query TT
|
||||
explain select first_value(i IGNORE NULLS) over () from integers
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
#
|
||||
query TT
|
||||
explain select first_value(i) over (), last_value(i) over () from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.* WINDOW .*
|
||||
|
||||
query TT
|
||||
explain select last_value(i) over (), first_value(i) over () from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.* WINDOW .*
|
||||
|
||||
query TT
|
||||
explain select first_value(i) over (), last_value(i) over (order by j) from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.* WINDOW .*
|
||||
|
||||
query TT
|
||||
explain select last_value(i) over (order by j), first_value(i) over () from integers
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.* WINDOW .*
|
||||
|
||||
#
|
||||
# Global state tests from #3275
|
||||
#
|
||||
|
||||
# Original UNION ALL bug
|
||||
statement ok
|
||||
CREATE TABLE v1(id bigint);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE v2(id bigint);
|
||||
|
||||
statement ok
|
||||
INSERT INTO v1 VALUES (11), (12), (13);
|
||||
|
||||
statement ok
|
||||
INSERT INTO v2 VALUES (21), (22);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW vertices_view AS
|
||||
SELECT * FROM v1
|
||||
UNION ALL
|
||||
SELECT * FROM v2;
|
||||
|
||||
query II
|
||||
SELECT id AS sparse_id, row_number() OVER () AS rnum
|
||||
FROM vertices_view;
|
||||
----
|
||||
11 1
|
||||
12 2
|
||||
13 3
|
||||
21 4
|
||||
22 5
|
||||
|
||||
# Recursive CTE
|
||||
query II
|
||||
WITH RECURSIVE rte AS (
|
||||
SELECT 1 l, 1::BIGINT r
|
||||
UNION ALL
|
||||
SELECT l+1, row_number() OVER()
|
||||
FROM rte
|
||||
WHERE l < 3
|
||||
)
|
||||
SELECT * FROM rte;
|
||||
----
|
||||
1 1
|
||||
2 1
|
||||
3 1
|
||||
|
||||
# In a prepared statement that is executed multiple times
|
||||
statement ok
|
||||
PREPARE sw1 AS
|
||||
SELECT i, row_number() OVER() AS row_no
|
||||
FROM range(10, 20) tbl(i)
|
||||
QUALIFY row_no <= ?::BIGINT
|
||||
;
|
||||
|
||||
query II
|
||||
EXECUTE sw1(10);
|
||||
----
|
||||
10 1
|
||||
11 2
|
||||
12 3
|
||||
13 4
|
||||
14 5
|
||||
15 6
|
||||
16 7
|
||||
17 8
|
||||
18 9
|
||||
19 10
|
||||
|
||||
query II
|
||||
EXECUTE sw1(2);
|
||||
----
|
||||
10 1
|
||||
11 2
|
||||
|
||||
# Struct Slicing
|
||||
query I
|
||||
from (values ({'key': 'A'}), ({'key': 'B'}), ({'key': 'C'}))
|
||||
select
|
||||
list(col0) over (rows between unbounded preceding and current row) as result
|
||||
----
|
||||
[{'key': A}]
|
||||
[{'key': A}, {'key': B}]
|
||||
[{'key': A}, {'key': B}, {'key': C}]
|
||||
|
||||
# Reset argument test (fails in debug)
|
||||
statement ok
|
||||
CREATE TABLE issue17621(i INT, j INT, k INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue17621 VALUES (1,1,1),
|
||||
(1,4,1),
|
||||
(1,2,1),
|
||||
(1,4,1),
|
||||
(1,4,1),
|
||||
(1,1,2),
|
||||
(1,4,2),
|
||||
(1,2,2),
|
||||
(1,4,2),
|
||||
(1,1,3),
|
||||
(1,4,3),
|
||||
(1,2,3),
|
||||
(1,4,3),
|
||||
(1,1,4),
|
||||
(1,4,4),
|
||||
(1,2,4),
|
||||
(1,4,4);
|
||||
|
||||
# No data because scan order is non-deterministic.
|
||||
statement ok
|
||||
SELECT
|
||||
k,
|
||||
STDDEV_POP(i),
|
||||
SUM(j),
|
||||
STDDEV_SAMP(k) OVER (ROWS UNBOUNDED PRECEDING) std_wf
|
||||
FROM issue17621
|
||||
GROUP BY ROLLUP(k)
|
||||
87
external/duckdb/test/sql/window/test_streaming_window_distinct.test
vendored
Normal file
87
external/duckdb/test/sql/window/test_streaming_window_distinct.test
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# name: test/sql/window/test_streaming_window_distinct.test
|
||||
# description: Test streaming window support for DISTINCT (+FILTER)
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA explain_output = PHYSICAL_ONLY;
|
||||
|
||||
# DISTINCT only
|
||||
query TT
|
||||
explain
|
||||
SELECT i,
|
||||
SUM(DISTINCT i % 3) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
FROM range(10) tbl(i)
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i,
|
||||
SUM(DISTINCT i % 3) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
FROM range(10) tbl(i)
|
||||
----
|
||||
0 0
|
||||
1 1
|
||||
2 3
|
||||
3 3
|
||||
4 3
|
||||
5 3
|
||||
6 3
|
||||
7 3
|
||||
8 3
|
||||
9 3
|
||||
|
||||
# DISTINCT LISTs
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT
|
||||
LIST(DISTINCT col0) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS result
|
||||
FROM (VALUES ({'key': 'A'}), ({'key': 'B'}), ({'key': 'A'}))
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query I
|
||||
SELECT
|
||||
LIST(DISTINCT col0) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS result
|
||||
FROM (VALUES ({'key': 'A'}), ({'key': 'B'}), ({'key': 'A'}))
|
||||
----
|
||||
[{'key': A}]
|
||||
[{'key': A}, {'key': B}]
|
||||
[{'key': A}, {'key': B}]
|
||||
|
||||
# DISTINCT + FILTER
|
||||
query TT
|
||||
explain
|
||||
SELECT i,
|
||||
SUM(DISTINCT i % 5) FILTER (i % 3 = 0) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
FROM range(20) tbl(i)
|
||||
----
|
||||
physical_plan <REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
query II
|
||||
SELECT i,
|
||||
SUM(DISTINCT i % 5) FILTER (i % 3 = 0) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
|
||||
FROM range(20) tbl(i)
|
||||
----
|
||||
0 0
|
||||
1 0
|
||||
2 0
|
||||
3 3
|
||||
4 3
|
||||
5 3
|
||||
6 4
|
||||
7 4
|
||||
8 4
|
||||
9 8
|
||||
10 8
|
||||
11 8
|
||||
12 10
|
||||
13 10
|
||||
14 10
|
||||
15 10
|
||||
16 10
|
||||
17 10
|
||||
18 10
|
||||
19 10
|
||||
17
external/duckdb/test/sql/window/test_streaming_window_list.test_slow
vendored
Normal file
17
external/duckdb/test/sql/window/test_streaming_window_list.test_slow
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# name: test/sql/window/test_streaming_window_list.test_slow
|
||||
# description: Streaming window with LIST aggregate
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
select
|
||||
list(row_number) over(rows between unbounded preceding and current row)
|
||||
from generate_series(5000) t(row_number);
|
||||
|
||||
query IIII
|
||||
SELECT COUNT(*), SUM(LENGTH(list_aggr)), MIN(LENGTH(list_aggr)), MAX(LENGTH(list_aggr)) FROM (
|
||||
select
|
||||
list(row_number) over(rows between unbounded preceding and current row)
|
||||
from generate_series(5000) t(row_number)
|
||||
) t(list_aggr)
|
||||
----
|
||||
5001 12507501 1 5001
|
||||
15
external/duckdb/test/sql/window/test_thread_count.test
vendored
Normal file
15
external/duckdb/test/sql/window/test_thread_count.test
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# name: test/sql/window/test_thread_count.test
|
||||
# description: Check the task thread allocation does not exceed what is provided
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
select row_number() over ()
|
||||
, count(distinct upper_ch1_ch2) over()::int as num_bigrams
|
||||
, sum(count_ch1_ch2) over () as bigram_count_all
|
||||
, count_ch1_ch2 / bigram_count_all as actual_bigram_frequency
|
||||
, ch1.actual_frequency * ch2.actual_frequency as expected_bigram_frequency
|
||||
from read_csv('data/csv/issue_13525/stat_bigrams.csv') as stat_bigrams
|
||||
inner join read_csv('data/csv/issue_13525/stat_stat_chars.csv') as ch1
|
||||
on stat_bigrams.ascii_upper_ch1 = ch1.ascii_upper_ch
|
||||
inner join read_csv('data/csv/issue_13525/stat_stat_chars.csv') as ch2
|
||||
on stat_bigrams.ascii_upper_ch2 = ch2.ascii_upper_ch;
|
||||
419
external/duckdb/test/sql/window/test_tpcc_results.test
vendored
Normal file
419
external/duckdb/test/sql/window/test_tpcc_results.test
vendored
Normal file
@@ -0,0 +1,419 @@
|
||||
# name: test/sql/window/test_tpcc_results.test
|
||||
# description: Framed secondary ordering test from Vogelsgesang et al. §2.4
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Version 5 Results As of 23-Dec-2024 at 7:54 PM [GMT]
|
||||
# https://www.tpc.org/tpcc/results/tpcc_results5.asp
|
||||
query IIIIIIIII
|
||||
select
|
||||
submission_date,
|
||||
dbsystem,
|
||||
tps,
|
||||
count(distinct dbsystem) over w AS competing,
|
||||
rank(order by tps desc) over w AS new_rank,
|
||||
first_value(tps order by tps desc) over w AS best_performance,
|
||||
first_value(dbsystem order by tps desc) over w AS best_system,
|
||||
lead(tps order by tps desc) over w AS second_performance,
|
||||
lead(dbsystem order by tps desc, dbsystem) over w AS second_system,
|
||||
from 'data/csv/tpcc_results.csv'
|
||||
window w as (
|
||||
order by submission_date
|
||||
range between unbounded preceding and current row
|
||||
)
|
||||
ORDER BY ALL;
|
||||
----
|
||||
2000-06-21 Sybase Adaptive Server Enterprise 12.0 60366.82 1 1 60366.82 Sybase Adaptive Server Enterprise 12.0 NULL NULL
|
||||
2001-03-19 IBM DB2 for AS/400 V4 R5 152346.25 3 2 163775.8 IBM DB2 for AS/400 V4 R5 60366.82 Sybase Adaptive Server Enterprise 12.0
|
||||
2001-03-19 IBM DB2 for AS/400 V4 R5 163775.8 3 1 163775.8 IBM DB2 for AS/400 V4 R5 152346.25 IBM DB2 for AS/400 V4 R5
|
||||
2001-03-19 Microsoft SQL Server 2000 20320.7 3 9 163775.8 IBM DB2 for AS/400 V4 R5 NULL NULL
|
||||
2001-03-19 Microsoft SQL Server 2000 20331.91 3 8 163775.8 IBM DB2 for AS/400 V4 R5 20320.7 Microsoft SQL Server 2000
|
||||
2001-03-19 Microsoft SQL Server 2000 24925.43 3 6 163775.8 IBM DB2 for AS/400 V4 R5 20331.91 Microsoft SQL Server 2000
|
||||
2001-03-19 Microsoft SQL Server 2000 24925.43 3 6 163775.8 IBM DB2 for AS/400 V4 R5 24925.43 Microsoft SQL Server 2000
|
||||
2001-03-19 Microsoft SQL Server 2000 30231.37 3 4 163775.8 IBM DB2 for AS/400 V4 R5 24925.43 Microsoft SQL Server 2000
|
||||
2001-03-19 Microsoft SQL Server 2000 30231.37 3 4 163775.8 IBM DB2 for AS/400 V4 R5 30231.37 Microsoft SQL Server 2000
|
||||
2001-03-20 Oracle 8 Enterprise Edition v8.1.7.1 66750.27 4 3 163775.8 IBM DB2 for AS/400 V4 R5 60366.82 Sybase Adaptive Server Enterprise 12.0
|
||||
2001-03-27 Microsoft SQL Server 2000 37383.57 4 5 163775.8 IBM DB2 for AS/400 V4 R5 30231.37 Microsoft SQL Server 2000
|
||||
2001-03-30 Microsoft SQL Server 2000 16262.9 4 12 163775.8 IBM DB2 for AS/400 V4 R5 NULL NULL
|
||||
2001-04-02 Microsoft SQL Server 2000 57014.93 4 5 163775.8 IBM DB2 for AS/400 V4 R5 37383.57 Microsoft SQL Server 2000
|
||||
2001-04-03 Oracle 8 Enterprise Edition v8.1.7.1 71863.02 6 4 163775.8 IBM DB2 for AS/400 V4 R5 66750.27 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-04-03 Oracle 8i Enterprise Edition v. 8.1.7 155179.25 6 2 163775.8 IBM DB2 for AS/400 V4 R5 152346.25 IBM DB2 for AS/400 V4 R5
|
||||
2001-04-03 Sybase Adaptive Server Enterprise 12.0.0.3 37274.0 6 9 163775.8 IBM DB2 for AS/400 V4 R5 30231.37 Microsoft SQL Server 2000
|
||||
2001-04-03 Sybase Adaptive Server Enterprise 12.0.0.3 37274.0 6 9 163775.8 IBM DB2 for AS/400 V4 R5 37274.0 Sybase Adaptive Server Enterprise 12.0.0.3
|
||||
2001-04-05 Sybase Adaptive Server Enterprise 11.9.3 22422.5 7 18 163775.8 IBM DB2 for AS/400 V4 R5 20331.91 Microsoft SQL Server 2000
|
||||
2001-04-05 Sybase Adaptive Server Enterprise 11.9.3 49308.0 7 9 163775.8 IBM DB2 for AS/400 V4 R5 37383.57 Microsoft SQL Server 2000
|
||||
2001-04-05 Sybase Adaptive Server Enterprise 12.0 34288.77 7 13 163775.8 IBM DB2 for AS/400 V4 R5 30231.37 Microsoft SQL Server 2000
|
||||
2001-04-05 Sybase Adaptive Server Enterprise 12.0 60366.82 7 6 163775.8 IBM DB2 for AS/400 V4 R5 57014.93 Microsoft SQL Server 2000
|
||||
2001-04-10 Microsoft SQL Server 2000 121319.23 7 5 688220.9 Microsoft SQL Server 2000 71863.02 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-04-10 Microsoft SQL Server 2000 688220.9 7 1 688220.9 Microsoft SQL Server 2000 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-04-11 IBM DB2 UDB 7.1 440879.95 8 3 688220.9 Microsoft SQL Server 2000 363129.75 Microsoft SQL Server 2000
|
||||
2001-04-11 IBM DB2 UDB 7.1 440879.95 8 3 688220.9 Microsoft SQL Server 2000 440879.95 IBM DB2 UDB 7.1
|
||||
2001-04-11 Microsoft SQL Server 2000 363129.75 8 5 688220.9 Microsoft SQL Server 2000 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-04-11 Microsoft SQL Server 2000 688220.9 8 1 688220.9 Microsoft SQL Server 2000 440879.95 IBM DB2 UDB 7.1
|
||||
2001-04-12 Microsoft SQL Server 2000 32377.17 9 21 688220.9 Microsoft SQL Server 2000 30231.37 Microsoft SQL Server 2000
|
||||
2001-04-12 Microsoft SQL Server 2000 Enterprise Edition 34264.9 9 20 688220.9 Microsoft SQL Server 2000 32377.17 Microsoft SQL Server 2000
|
||||
2001-04-13 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0 222772.33 10 6 688220.9 Microsoft SQL Server 2000 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-04-23 Oracle Database 9i Enterprise Edition v.9.0.1 57346.93 11 15 688220.9 Microsoft SQL Server 2000 57014.93 Microsoft SQL Server 2000
|
||||
2001-04-24 Microsoft SQL Server 2000 136766.67 11 10 688220.9 Microsoft SQL Server 2000 121319.23 Microsoft SQL Server 2000
|
||||
2001-05-22 Microsoft SQL Server 2000 Enterprise Edition 52671.3 11 18 688220.9 Microsoft SQL Server 2000 49308.0 Sybase Adaptive Server Enterprise 11.9.3
|
||||
2001-05-28 Oracle 8i Enterprise Edition v. 8.1.7 66750.27 11 14 688220.9 Microsoft SQL Server 2000 60366.82 Sybase Adaptive Server Enterprise 12.0
|
||||
2001-05-28 Oracle 8i Enterprise Edition v. 8.1.7 220807.27 11 7 688220.9 Microsoft SQL Server 2000 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-06-18 Oracle Database 9i Enterprise Edition 230533.0 12 6 688220.9 Microsoft SQL Server 2000 222772.33 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2001-06-22 Oracle 8i Enterprise Edition v. 8.1.7 66750.27 12 16 688220.9 Microsoft SQL Server 2000 60366.82 Sybase Adaptive Server Enterprise 12.0
|
||||
2001-06-22 Oracle 8i Enterprise Edition v. 8.1.7 220807.27 12 8 688220.9 Microsoft SQL Server 2000 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-07-03 Oracle Database 9i Enterprise Edition v.9i.0.1 57346.93 13 21 688220.9 Microsoft SQL Server 2000 57014.93 Microsoft SQL Server 2000
|
||||
2001-07-27 Microsoft SQL Server 2000 20207.2 13 39 688220.9 Microsoft SQL Server 2000 16262.9 Microsoft SQL Server 2000
|
||||
2001-08-22 Microsoft SQL Server 2000 Enterprise Edition 69901.74 13 16 688220.9 Microsoft SQL Server 2000 66750.27 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-08-23 Microsoft SQL Server 2000 Enterprise Edition 37596.34 13 28 688220.9 Microsoft SQL Server 2000 37383.57 Microsoft SQL Server 2000
|
||||
2001-08-23 Microsoft SQL Server 2000 Enterprise Edition 43046.55 13 27 688220.9 Microsoft SQL Server 2000 37596.34 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2001-08-28 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0 455818.2 13 3 688220.9 Microsoft SQL Server 2000 440879.95 IBM DB2 UDB 7.1
|
||||
2001-09-10 Microsoft SQL Server 2000 Enterprise Edition 141138.44 13 14 688220.9 Microsoft SQL Server 2000 136766.67 Microsoft SQL Server 2000
|
||||
2001-09-10 Oracle Database 9i Enterprise Edition v.9i.0.1 105025.02 13 17 688220.9 Microsoft SQL Server 2000 71863.02 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-09-19 Microsoft SQL Server 2000 Enterprise Edition 410769.88 13 8 709220.08 Microsoft SQL Server 2000 Enterprise Edition 363129.75 Microsoft SQL Server 2000
|
||||
2001-09-19 Microsoft SQL Server 2000 Enterprise Edition 567882.56 13 4 709220.08 Microsoft SQL Server 2000 Enterprise Edition 455818.2 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2001-09-19 Microsoft SQL Server 2000 Enterprise Edition 709220.08 13 1 709220.08 Microsoft SQL Server 2000 Enterprise Edition 688220.9 Microsoft SQL Server 2000
|
||||
2001-09-25 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0 67102.53 13 23 709220.08 Microsoft SQL Server 2000 Enterprise Edition 66750.27 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-09-25 Microsoft SQL Server 2000 9347.24 13 51 709220.08 Microsoft SQL Server 2000 Enterprise Edition NULL NULL
|
||||
2001-09-26 Microsoft SQL Server 2000 Enterprise Edition 17335.75 13 51 709220.08 Microsoft SQL Server 2000 Enterprise Edition 16262.9 Microsoft SQL Server 2000
|
||||
2001-09-26 Oracle Database 9i Enterprise Edition v.9i.0.1 105025.02 13 20 709220.08 Microsoft SQL Server 2000 Enterprise Edition 71863.02 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2001-09-27 Microsoft SQL Server 2000 Enterprise Edition 39158.09 13 36 709220.08 Microsoft SQL Server 2000 Enterprise Edition 37596.34 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2001-10-01 Microsoft SQL Server 2000 20422.01 13 49 709220.08 Microsoft SQL Server 2000 Enterprise Edition 20331.91 Microsoft SQL Server 2000
|
||||
2001-10-16 Microsoft SQL Server 2000 Standard Edition 9112.91 14 56 709220.08 Microsoft SQL Server 2000 Enterprise Edition NULL NULL
|
||||
2001-10-25 Microsoft SQL Server 2000 Enterprise Edition 22007.12 14 49 709220.08 Microsoft SQL Server 2000 Enterprise Edition 20422.01 Microsoft SQL Server 2000
|
||||
2001-10-31 Microsoft SQL Server 2000 Standard Edition 11320.02 14 56 709220.08 Microsoft SQL Server 2000 Enterprise Edition 9347.24 Microsoft SQL Server 2000
|
||||
2001-11-05 Microsoft SQL Server 2000 Standard Edition 15533.72 14 56 709220.08 Microsoft SQL Server 2000 Enterprise Edition 11320.02 Microsoft SQL Server 2000 Standard Edition
|
||||
2001-11-11 Microsoft SQL Server 2000 Enterprise Edition 165218.71 14 14 709220.08 Microsoft SQL Server 2000 Enterprise Edition 163775.8 IBM DB2 for AS/400 V4 R5
|
||||
2001-11-11 Microsoft SQL Server 2000 Enterprise Edition 165218.71 14 14 709220.08 Microsoft SQL Server 2000 Enterprise Edition 165218.71 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2001-11-12 Microsoft SQL Server 2000 Enterprise Edition 37100.52 14 43 709220.08 Microsoft SQL Server 2000 Enterprise Edition 34288.77 Sybase Adaptive Server Enterprise 12.0
|
||||
2001-12-14 Microsoft SQL Server 2000 Standard Edition 11314.11 14 61 709220.08 Microsoft SQL Server 2000 Enterprise Edition 9347.24 Microsoft SQL Server 2000
|
||||
2001-12-21 Oracle 8 Enterprise Edition v8.1.7.1 197024.17 15 15 709220.08 Microsoft SQL Server 2000 Enterprise Edition 165218.71 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2001-12-21 Oracle Database 9i Enterprise Edition 389434.4 15 9 709220.08 Microsoft SQL Server 2000 Enterprise Edition 363129.75 Microsoft SQL Server 2000
|
||||
2001-12-21 Sybase Adaptive Server Enterprise v12.5 140239.97 15 22 709220.08 Microsoft SQL Server 2000 Enterprise Edition 136766.67 Microsoft SQL Server 2000
|
||||
2002-01-28 Oracle Database 9i R2 Enterprise Edition for Tru64 Unix 50117.0 16 39 709220.08 Microsoft SQL Server 2000 Enterprise Edition 49308.0 Sybase Adaptive Server Enterprise 11.9.3
|
||||
2002-02-08 Microsoft SQL Server 2000 Enterprise Edition 29860.12 16 53 709220.08 Microsoft SQL Server 2000 Enterprise Edition 24925.43 Microsoft SQL Server 2000
|
||||
2002-02-13 Microsoft SQL Server 2000 Standard Edition 17078.88 16 63 709220.08 Microsoft SQL Server 2000 Enterprise Edition 16262.9 Microsoft SQL Server 2000
|
||||
2002-02-25 Microsoft SQL Server 2000 Enterprise Edition 33768.41 16 51 709220.08 Microsoft SQL Server 2000 Enterprise Edition 32377.17 Microsoft SQL Server 2000
|
||||
2002-02-25 Microsoft SQL Server 2000 Enterprise Edition 69169.61 16 29 709220.08 Microsoft SQL Server 2000 Enterprise Edition 67102.53 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2002-03-11 Microsoft SQL Server 2000 Enterprise Edition 55138.6 16 39 709220.08 Microsoft SQL Server 2000 Enterprise Edition 52671.3 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-03-11 Microsoft SQL Server 2000 Standard Edition 23027.66 16 59 709220.08 Microsoft SQL Server 2000 Enterprise Edition 22422.5 Sybase Adaptive Server Enterprise 11.9.3
|
||||
2002-03-12 Microsoft SQL Server 2000 Enterprise Edition 48906.18 16 44 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43046.55 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-03-12 Microsoft SQL Server 2000 Standard Edition 11537.02 16 72 709220.08 Microsoft SQL Server 2000 Enterprise Edition 11320.02 Microsoft SQL Server 2000 Standard Edition
|
||||
2002-03-12 Microsoft SQL Server 2000 Standard Edition 11537.02 16 72 709220.08 Microsoft SQL Server 2000 Enterprise Edition 11537.02 Microsoft SQL Server 2000 Standard Edition
|
||||
2002-03-12 Sybase Adaptive Server Enterprise v12.5 112286.46 16 25 709220.08 Microsoft SQL Server 2000 Enterprise Edition 105025.02 Oracle Database 9i Enterprise Edition v.9i.0.1
|
||||
2002-04-23 Microsoft SQL Server 2000 Enterprise Edition 34473.15 16 52 709220.08 Microsoft SQL Server 2000 Enterprise Edition 34288.77 Sybase Adaptive Server Enterprise 12.0
|
||||
2002-04-23 Microsoft SQL Server 2000 Enterprise Edition 34473.15 16 52 709220.08 Microsoft SQL Server 2000 Enterprise Edition 34473.15 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-05-17 Microsoft SQL Server 2000 Enterprise Edition 48911.83 16 44 709220.08 Microsoft SQL Server 2000 Enterprise Edition 48906.18 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-05-24 Microsoft SQL Server 2000 Enterprise Edition 48906.18 16 45 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43046.55 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-06-01 Microsoft SQL Server 2000 Enterprise Edition 34819.03 16 55 709220.08 Microsoft SQL Server 2000 Enterprise Edition 34473.15 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-06-01 Microsoft SQL Server 2000 Enterprise Edition 34914.92 16 54 709220.08 Microsoft SQL Server 2000 Enterprise Edition 34819.03 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-06-03 Microsoft SQL Server 2000 Standard Edition 12009.46 17 79 709220.08 Microsoft SQL Server 2000 Enterprise Edition 11537.02 Microsoft SQL Server 2000 Standard Edition
|
||||
2002-06-03 Oracle Database 9i R2 Enterprise Edition 403255.46 17 9 709220.08 Microsoft SQL Server 2000 Enterprise Edition 389434.4 Oracle Database 9i Enterprise Edition
|
||||
2002-06-04 Oracle Database 9i R2 Enterprise Edition 137260.89 17 24 709220.08 Microsoft SQL Server 2000 Enterprise Edition 136766.67 Microsoft SQL Server 2000
|
||||
2002-06-20 Microsoft SQL Server 2000 Enterprise Edition 48150.72 17 49 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43046.55 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-06-20 Microsoft SQL Server 2000 Enterprise Edition 48150.72 17 49 709220.08 Microsoft SQL Server 2000 Enterprise Edition 48150.72 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-06-26 Microsoft SQL Server 2000 Standard Edition 12579.04 17 82 709220.08 Microsoft SQL Server 2000 Enterprise Edition 12009.46 Microsoft SQL Server 2000 Standard Edition
|
||||
2002-07-08 Microsoft SQL Server 2000 Enterprise Edition 64bit 40621.26 18 53 709220.08 Microsoft SQL Server 2000 Enterprise Edition 39158.09 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-07-08 Microsoft SQL Server 2000 Enterprise Edition 64bit 78454.76 18 30 709220.08 Microsoft SQL Server 2000 Enterprise Edition 71863.02 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2002-07-17 Microsoft SQL Server 2000 Enterprise Edition 45230.03 18 52 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43046.55 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-07-22 Microsoft SQL Server 2000 Enterprise Edition 92398.49 18 30 709220.08 Microsoft SQL Server 2000 Enterprise Edition 78454.76 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2002-07-25 Microsoft SQL Server 2000 Standard Edition 17659.53 18 82 709220.08 Microsoft SQL Server 2000 Enterprise Edition 17335.75 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-07-26 Microsoft SQL Server 2000 Enterprise Edition SP2 33768.41 19 68 709220.08 Microsoft SQL Server 2000 Enterprise Edition 32377.17 Microsoft SQL Server 2000
|
||||
2002-08-05 Sybase Adaptive Server Enterprise v12.5 56375.0 19 44 709220.08 Microsoft SQL Server 2000 Enterprise Edition 55138.6 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-08-13 Microsoft SQL Server 2000 Standard Edition SP3 10089.76 20 95 709220.08 Microsoft SQL Server 2000 Enterprise Edition 9347.24 Microsoft SQL Server 2000
|
||||
2002-08-15 Oracle Database 9i R2 Enterprise Edition 403255.46 20 9 709220.08 Microsoft SQL Server 2000 Enterprise Edition 389434.4 Oracle Database 9i Enterprise Edition
|
||||
2002-08-16 Microsoft SQL Server 2000 Standard Edition SP3 17559.31 20 86 709220.08 Microsoft SQL Server 2000 Enterprise Edition 17335.75 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-08-20 Microsoft SQL Server 2000 Enterprise Edition SP2 61168.83 20 40 709220.08 Microsoft SQL Server 2000 Enterprise Edition 60366.82 Sybase Adaptive Server Enterprise 12.0
|
||||
2002-08-23 Microsoft SQL Server 2000 Enterprise Edition 61564.5 20 40 709220.08 Microsoft SQL Server 2000 Enterprise Edition 61168.83 Microsoft SQL Server 2000 Enterprise Edition SP2
|
||||
2002-08-26 Oracle Database 9i Enterprise Server v.9.2.0.1 423414.41 21 8 709220.08 Microsoft SQL Server 2000 Enterprise Edition 410769.88 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-09-11 Microsoft SQL Server 2000 Enterprise Edition 16756.52 21 92 709220.08 Microsoft SQL Server 2000 Enterprise Edition 16262.9 Microsoft SQL Server 2000
|
||||
2002-09-16 Oracle Database 9i R2 Enterprise Edition 138362.03 21 26 709220.08 Microsoft SQL Server 2000 Enterprise Edition 137260.89 Oracle Database 9i R2 Enterprise Edition
|
||||
2002-10-07 Microsoft SQL Server 2000 Enterprise Edition SP3 84598.42 22 34 709220.08 Microsoft SQL Server 2000 Enterprise Edition 78454.76 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2002-10-30 Microsoft SQL Server 2000 Enterprise Edition 51069.87 22 53 709220.08 Microsoft SQL Server 2000 Enterprise Edition 50117.0 Oracle Database 9i R2 Enterprise Edition for Tru64 Unix
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition 203518.03 22 18 709220.08 Microsoft SQL Server 2000 Enterprise Edition 197024.17 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition SP3 68264.47 22 44 709220.08 Microsoft SQL Server 2000 Enterprise Edition 67102.53 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition SP3 68739.22 22 43 709220.08 Microsoft SQL Server 2000 Enterprise Edition 68264.47 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition SP3 74206.27 22 39 709220.08 Microsoft SQL Server 2000 Enterprise Edition 71863.02 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition SP3 111024.39 22 33 709220.08 Microsoft SQL Server 2000 Enterprise Edition 105025.02 Oracle Database 9i Enterprise Edition v.9i.0.1
|
||||
2002-11-04 Microsoft SQL Server 2000 Enterprise Edition SP3 111805.22 22 32 709220.08 Microsoft SQL Server 2000 Enterprise Edition 111024.39 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2002-11-08 Microsoft SQL Server 2000 Enterprise Edition SP3 112740.87 22 31 709220.08 Microsoft SQL Server 2000 Enterprise Edition 112286.46 Sybase Adaptive Server Enterprise v12.5
|
||||
2002-11-12 Oracle Database 10i Standard Edition 80494.98 23 39 709220.08 Microsoft SQL Server 2000 Enterprise Edition 78454.76 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2002-11-13 Oracle Database 10i Standard Edition 80570.81 23 39 709220.08 Microsoft SQL Server 2000 Enterprise Edition 80494.98 Oracle Database 10i Standard Edition
|
||||
2002-11-19 Microsoft SQL Server 2000 Enterprise Edition SP3 77905.18 23 42 709220.08 Microsoft SQL Server 2000 Enterprise Edition 74206.27 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2002-11-19 Microsoft SQL Server 2000 Standard Edition SP3 18051.65 23 101 709220.08 Microsoft SQL Server 2000 Enterprise Edition 17659.53 Microsoft SQL Server 2000 Standard Edition
|
||||
2002-12-04 Microsoft SQL Server 2000 Standard Edition SP3 18077.98 23 101 709220.08 Microsoft SQL Server 2000 Enterprise Edition 18051.65 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2002-12-06 Microsoft SQL Server 2000 Enterprise Edition SP3 115025.75 23 31 709220.08 Microsoft SQL Server 2000 Enterprise Edition 112740.87 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2002-12-09 Microsoft SQL Server 2000 Enterprise Edition 234325.1 23 14 709220.08 Microsoft SQL Server 2000 Enterprise Edition 230533.0 Oracle Database 9i Enterprise Edition
|
||||
2002-12-12 Microsoft SQL Server 2000 Enterprise Edition 64bit 342746.25 23 14 709220.08 Microsoft SQL Server 2000 Enterprise Edition 234325.1 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2002-12-16 Microsoft SQL Server 2000 Enterprise Edition 64bit 87741.0 23 41 709220.08 Microsoft SQL Server 2000 Enterprise Edition 84598.42 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2002-12-26 Oracle Database 9i Enterprise Server v.9.2.0.1 427760.83 23 8 709220.08 Microsoft SQL Server 2000 Enterprise Edition 423414.41 Oracle Database 9i Enterprise Server v.9.2.0.1
|
||||
2003-01-06 Microsoft SQL Server 2000 Enterprise Edition SP3 71313.19 23 51 709220.08 Microsoft SQL Server 2000 Enterprise Edition 69901.74 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-01-06 Microsoft SQL Server 2000 Enterprise Edition SP3 71586.49 23 50 709220.08 Microsoft SQL Server 2000 Enterprise Edition 71313.19 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-01-08 Microsoft SQL Server 2000 Enterprise Edition SP3 26725.34 23 100 709220.08 Microsoft SQL Server 2000 Enterprise Edition 24925.43 Microsoft SQL Server 2000
|
||||
2003-01-08 Microsoft SQL Server 2000 Enterprise Edition SP3 26725.34 23 100 709220.08 Microsoft SQL Server 2000 Enterprise Edition 26725.34 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-01-08 Microsoft SQL Server 2000 Enterprise Edition SP3 38386.24 23 82 709220.08 Microsoft SQL Server 2000 Enterprise Edition 37596.34 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-01-22 Microsoft SQL Server 2000 Enterprise Edition SP3 68264.47 23 56 709220.08 Microsoft SQL Server 2000 Enterprise Edition 67102.53 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2003-01-22 Microsoft SQL Server 2000 Enterprise Edition SP3 84598.42 23 43 709220.08 Microsoft SQL Server 2000 Enterprise Edition 80570.81 Oracle Database 10i Standard Edition
|
||||
2003-02-20 Microsoft SQL Server 2000 Enterprise Edition 64bit 433107.77 23 8 709220.08 Microsoft SQL Server 2000 Enterprise Edition 427760.83 Oracle Database 9i Enterprise Server v.9.2.0.1
|
||||
2003-02-28 Microsoft SQL Server 2000 Enterprise Edition SP3 50666.11 23 75 709220.08 Microsoft SQL Server 2000 Enterprise Edition 50117.0 Oracle Database 9i R2 Enterprise Edition for Tru64 Unix
|
||||
2003-02-28 Microsoft SQL Server 2000 Enterprise Edition SP3 52587.46 23 73 709220.08 Microsoft SQL Server 2000 Enterprise Edition 51069.87 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-03-26 Microsoft SQL Server 2000 Enterprise Edition SP3 151744.13 23 29 709220.08 Microsoft SQL Server 2000 Enterprise Edition 141138.44 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-03-26 Microsoft SQL Server 2000 Enterprise Edition SP3 151744.13 23 29 709220.08 Microsoft SQL Server 2000 Enterprise Edition 151744.13 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-04-04 Microsoft SQL Server 2000 Enterprise Edition 118381.38 23 38 709220.08 Microsoft SQL Server 2000 Enterprise Edition 115025.75 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-04-04 Microsoft SQL Server 2000 Enterprise Edition SP3 119115.16 23 37 709220.08 Microsoft SQL Server 2000 Enterprise Edition 118381.38 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-04-09 Microsoft SQL Server 2000 Enterprise Edition 70653.01 23 58 709220.08 Microsoft SQL Server 2000 Enterprise Edition 69901.74 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-04-21 Microsoft SQL Server 2000 Enterprise Edition SP3 78116.87 23 53 709220.08 Microsoft SQL Server 2000 Enterprise Edition 77905.18 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-04-23 Microsoft SQL Server 2000 Enterprise Edition 64bit 514034.72 23 5 709220.08 Microsoft SQL Server 2000 Enterprise Edition 455818.2 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2003-04-24 Microsoft SQL Server 2000 Enterprise Edition 64bit 121065.13 23 40 709220.08 Microsoft SQL Server 2000 Enterprise Edition 119115.16 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-04-24 Microsoft SQL Server 2000 Enterprise Edition 64bit 658277.74 23 4 709220.08 Microsoft SQL Server 2000 Enterprise Edition 567882.56 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-04-24 Microsoft SQL Server 2000 Enterprise Edition 64bit 658277.74 23 4 709220.08 Microsoft SQL Server 2000 Enterprise Edition 658277.74 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-05-02 Microsoft SQL Server 2000 Enterprise Edition 181280.45 23 27 709220.08 Microsoft SQL Server 2000 Enterprise Edition 165218.71 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-05-09 IBM DB2 UDB 8.1 680613.12 24 4 709220.08 Microsoft SQL Server 2000 Enterprise Edition 658277.74 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-05-12 Microsoft SQL Server 2000 19526.27 24 129 709220.08 Microsoft SQL Server 2000 Enterprise Edition 18077.98 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2003-05-12 Microsoft SQL Server 2000 Enterprise Edition SP3 39006.54 24 99 709220.08 Microsoft SQL Server 2000 Enterprise Edition 38386.24 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-05-16 Microsoft SQL Server 2000 Enterprise Edition 161542.04 24 33 709220.08 Microsoft SQL Server 2000 Enterprise Edition 155179.25 Oracle 8i Enterprise Edition v. 8.1.7
|
||||
2003-05-16 Microsoft SQL Server 2000 Enterprise Edition 64bit 707102.32 24 2 709220.08 Microsoft SQL Server 2000 Enterprise Edition 688220.9 Microsoft SQL Server 2000
|
||||
2003-05-20 Microsoft SQL Server 2000 Enterprise Edition 64bit 707102.0 24 3 709220.08 Microsoft SQL Server 2000 Enterprise Edition 688220.9 Microsoft SQL Server 2000
|
||||
2003-05-29 Microsoft SQL Server 2000 Enterprise Edition SP3 43230.66 24 100 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43046.55 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-05-29 Microsoft SQL Server 2000 Enterprise Edition SP3 44942.92 24 99 709220.08 Microsoft SQL Server 2000 Enterprise Edition 43230.66 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-05-29 Microsoft SQL Server 2000 Standard Edition SP3 18818.46 24 136 709220.08 Microsoft SQL Server 2000 Enterprise Edition 18077.98 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2003-05-29 Microsoft SQL Server 2000 Standard Edition SP3 19140.72 24 135 709220.08 Microsoft SQL Server 2000 Enterprise Edition 18818.46 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2003-06-27 Microsoft SQL Server 2000 Enterprise Edition 252920.49 24 23 709220.08 Microsoft SQL Server 2000 Enterprise Edition 234325.1 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-06-30 IBM DB2 UDB 8.1 763898.39 24 1 763898.39 IBM DB2 UDB 8.1 709220.08 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-06-30 Microsoft SQL Server 2000 Enterprise Edition SP3 84595.22 24 62 763898.39 IBM DB2 UDB 8.1 80570.81 Oracle Database 10i Standard Edition
|
||||
2003-06-30 Microsoft SQL Server 2000 Enterprise Edition SP3 139153.98 24 43 763898.39 IBM DB2 UDB 8.1 138362.03 Oracle Database 9i R2 Enterprise Edition
|
||||
2003-07-08 Microsoft SQL Server 2000 Enterprise Edition SP3 82226.46 24 63 763898.39 IBM DB2 UDB 8.1 80570.81 Oracle Database 10i Standard Edition
|
||||
2003-07-10 Microsoft SQL Server 2000 Enterprise Edition 18936.05 24 141 763898.39 IBM DB2 UDB 8.1 18818.46 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2003-07-14 Microsoft SQL Server 2000 Standard Edition 20108.79 24 139 763898.39 IBM DB2 UDB 8.1 19526.27 Microsoft SQL Server 2000
|
||||
2003-07-15 Microsoft SQL Server 2000 Enterprise Edition SP3 52468.48 24 94 763898.39 IBM DB2 UDB 8.1 51069.87 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-07-15 Microsoft SQL Server 2000 Standard Edition SP3 19718.01 24 141 763898.39 IBM DB2 UDB 8.1 19526.27 Microsoft SQL Server 2000
|
||||
2003-07-18 Microsoft SQL Server 2000 Enterprise Edition SP3 190510.02 24 32 763898.39 IBM DB2 UDB 8.1 181280.45 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-07-30 Oracle Database 10g Enterprise Edition 541673.76 26 12 824164.53 Oracle Database 10g Enterprise Edition 514034.72 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-07-30 Oracle Database 10g Enterprise Edition 824164.53 26 1 824164.53 Oracle Database 10g Enterprise Edition 763898.39 IBM DB2 UDB 8.1
|
||||
2003-07-30 Oracle Database 10g Standard Edition 131639.8 26 50 824164.53 Oracle Database 10g Enterprise Edition 121319.23 Microsoft SQL Server 2000
|
||||
2003-08-11 Microsoft SQL Server 2000 Enterprise Edition SP3 53691.33 26 96 824164.53 Oracle Database 10g Enterprise Edition 52671.3 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-08-27 Microsoft SQL Server 2000 Enterprise Edition 64bit 786646.0 26 2 824164.53 Oracle Database 10g Enterprise Edition 763898.39 IBM DB2 UDB 8.1
|
||||
2003-09-05 Oracle Database 10g Standard Edition 136110.98 26 51 824164.53 Oracle Database 10g Enterprise Edition 131639.8 Oracle Database 10g Standard Edition
|
||||
2003-09-08 Microsoft SQL Server 2000 Enterprise Edition SP3 84712.94 26 67 824164.53 Oracle Database 10g Enterprise Edition 84598.42 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-09-08 Microsoft SQL Server 2000 Standard Edition SP3 20477.37 26 145 824164.53 Oracle Database 10g Enterprise Edition 20422.01 Microsoft SQL Server 2000
|
||||
2003-09-08 Oracle Database 10g Enterprise Edition 521440.53 26 14 824164.53 Oracle Database 10g Enterprise Edition 514034.72 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-09-12 Oracle Database 10g Enterprise Edition 768839.4 26 3 824164.53 Oracle Database 10g Enterprise Edition 763898.39 IBM DB2 UDB 8.1
|
||||
2003-09-21 Microsoft SQL Server 2000 Enterprise Edition SP3 36027.71 26 127 824164.53 Oracle Database 10g Enterprise Edition 34914.92 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-10-09 Microsoft SQL Server 2000 Enterprise Edition 64bit 577530.77 26 13 824164.53 Oracle Database 10g Enterprise Edition 567882.56 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-10-13 Microsoft SQL Server 2000 Enterprise Edition SP3 54096.56 26 102 824164.53 Oracle Database 10g Enterprise Edition 53691.33 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2003-10-17 Microsoft SQL Server 2000 Enterprise Edition SP3 90271.76 26 68 824164.53 Oracle Database 10g Enterprise Edition 87741.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-10-20 Oracle Database 10g Enterprise Edition 291410.61 26 30 824164.53 Oracle Database 10g Enterprise Edition 252920.49 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-10-22 Microsoft SQL Server 2000 Enterprise Edition SP3 51226.96 26 109 824164.53 Oracle Database 10g Enterprise Edition 51069.87 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-10-31 Oracle Database 10g Enterprise Edition 595702.31 26 13 824164.53 Oracle Database 10g Enterprise Edition 577530.77 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-11-03 Microsoft SQL Server 2000 Enterprise Edition SP3 58161.52 26 100 824164.53 Oracle Database 10g Enterprise Edition 57346.93 Oracle Database 9i Enterprise Edition v.9.0.1
|
||||
2003-11-04 Oracle Database 10g Enterprise Edition 1008144.49 26 1 1008144.49 Oracle Database 10g Enterprise Edition 824164.53 Oracle Database 10g Enterprise Edition
|
||||
2003-11-24 Microsoft SQL Server 2000 Standard Edition SP3 19814.35 26 161 1008144.49 Oracle Database 10g Enterprise Edition 19718.01 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2003-12-03 Microsoft SQL Server 2000 Enterprise Edition SP3 31910.24 26 145 1008144.49 Oracle Database 10g Enterprise Edition 30231.37 Microsoft SQL Server 2000
|
||||
2003-12-08 Microsoft SQL Server 2000 Enterprise Edition SP3 89616.32 26 73 1184893.38 Oracle Database 10g Enterprise Edition 87741.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2003-12-08 Oracle Database 10g Enterprise Edition 1184893.38 26 1 1184893.38 Oracle Database 10g Enterprise Edition 1008144.49 Oracle Database 10g Enterprise Edition
|
||||
2003-12-17 Microsoft SQL Server 2000 Enterprise Edition SP3 33873.83 26 144 1184893.38 Oracle Database 10g Enterprise Edition 33768.41 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2003-12-17 Microsoft SQL Server 2000 Standard Edition SP3 17192.4 26 176 1184893.38 Oracle Database 10g Enterprise Edition 17078.88 Microsoft SQL Server 2000 Standard Edition
|
||||
2003-12-18 Microsoft SQL Server 2000 Enterprise Edition 64bit 301225.0 26 33 1184893.38 Oracle Database 10g Enterprise Edition 291410.61 Oracle Database 10g Enterprise Edition
|
||||
2004-01-20 Microsoft SQL Server 2000 Enterprise Edition 309036.53 26 33 1184893.38 Oracle Database 10g Enterprise Edition 301225.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2004-02-17 IBM DB2 UDB 8.1 1025486.07 26 2 1184893.38 Oracle Database 10g Enterprise Edition 1008144.49 Oracle Database 10g Enterprise Edition
|
||||
2004-02-18 Microsoft SQL Server 2000 Standard Edition 22052.0 26 162 1184893.38 Oracle Database 10g Enterprise Edition 22007.12 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-02-18 Microsoft SQL Server 2000 Standard Edition 22052.81 26 161 1184893.38 Oracle Database 10g Enterprise Edition 22052.0 Microsoft SQL Server 2000 Standard Edition
|
||||
2004-02-23 Microsoft SQL Server 2000 Enterprise Edition 32185.33 26 151 1184893.38 Oracle Database 10g Enterprise Edition 31910.24 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-03-01 Microsoft SQL Server 2000 Enterprise Edition 95163.0 26 76 1184893.38 Oracle Database 10g Enterprise Edition 92398.49 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-03-01 Microsoft SQL Server 2000 Enterprise Edition 102667.42 26 75 1184893.38 Oracle Database 10g Enterprise Edition 95163.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-03-01 Microsoft SQL Server 2000 Enterprise Edition 156105.72 26 51 1184893.38 Oracle Database 10g Enterprise Edition 155179.25 Oracle 8i Enterprise Edition v. 8.1.7
|
||||
2004-03-02 Microsoft SQL Server 2000 Enterprise Edition 28711.0 26 161 1184893.38 Oracle Database 10g Enterprise Edition 26725.34 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-03-02 Microsoft SQL Server 2000 Enterprise Edition 35030.0 26 145 1184893.38 Oracle Database 10g Enterprise Edition 34914.92 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-03-02 Microsoft SQL Server 2000 Enterprise Edition 60364.0 26 109 1184893.38 Oracle Database 10g Enterprise Edition 58161.52 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-03-26 Microsoft SQL Server 2000 Enterprise Edition SP3 215485.89 26 43 1184893.38 Oracle Database 10g Enterprise Edition 203518.03 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-04-06 Oracle Database 10g Enterprise Edition 609467.0 26 16 1184893.38 Oracle Database 10g Enterprise Edition 595702.31 Oracle Database 10g Enterprise Edition
|
||||
2004-04-14 IBM DB2 UDB Express Edition v8.1 18318.24 27 185 1184893.38 Oracle Database 10g Enterprise Edition 18077.98 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2004-04-28 Microsoft SQL Server 2000 Enterprise Edition 304148.5 27 36 1184893.38 Oracle Database 10g Enterprise Edition 301225.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2004-05-03 Microsoft SQL Server 2000 Enterprise Edition SP3 105687.0 27 77 1184893.38 Oracle Database 10g Enterprise Edition 105025.02 Oracle Database 9i Enterprise Edition v.9i.0.1
|
||||
2004-05-03 Microsoft SQL Server 2000 Enterprise Edition SP3 123027.0 27 67 1184893.38 Oracle Database 10g Enterprise Edition 121319.23 Microsoft SQL Server 2000
|
||||
2004-05-11 Microsoft SQL Server 2000 Enterprise Edition SP3 21197.0 27 177 1184893.38 Oracle Database 10g Enterprise Edition 20477.37 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2004-05-11 Oracle Database 10g Enterprise Edition 291413.0 27 38 1184893.38 Oracle Database 10g Enterprise Edition 291410.61 Oracle Database 10g Enterprise Edition
|
||||
2004-05-27 Microsoft SQL Server 2000 Enterprise Edition SP3 94172.0 27 83 1184893.38 Oracle Database 10g Enterprise Edition 92398.49 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-06-14 Microsoft SQL Server 2000 Enterprise Edition 212511.0 27 48 1184893.38 Oracle Database 10g Enterprise Edition 203518.03 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-06-14 Microsoft SQL Server 2000 Enterprise Edition 237869.0 27 41 1184893.38 Oracle Database 10g Enterprise Edition 234325.1 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-06-28 Oracle Database 10g Enterprise Edition 683575.0 27 13 1184893.38 Oracle Database 10g Enterprise Edition 680613.12 IBM DB2 UDB 8.1
|
||||
2004-06-30 Microsoft SQL Server 2000 Enterprise Edition 64bit 175366.24 27 54 1184893.38 Oracle Database 10g Enterprise Edition 165218.71 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-07-12 IBM DB2 UDB 8.1 809144.09 28 5 1184893.38 Oracle Database 10g Enterprise Edition 786646.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2004-07-12 Oracle Database 10g 194391.43 28 54 1184893.38 Oracle Database 10g Enterprise Edition 190510.02 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-07-12 Oracle Database 10g 371044.22 28 35 1184893.38 Oracle Database 10g Enterprise Edition 363129.75 Microsoft SQL Server 2000
|
||||
2004-07-16 IBM DB2 UDB Express Edition v8.1 18661.0 28 198 1184893.38 Oracle Database 10g Enterprise Edition 18318.24 IBM DB2 UDB Express Edition v8.1
|
||||
2004-07-20 Microsoft SQL Server 2000 Enterprise Edition SP3 85554.0 28 95 1184893.38 Oracle Database 10g Enterprise Edition 84712.94 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-08-13 Microsoft SQL Server 2000 Enterprise Edition SP3 34349.0 28 165 1184893.38 Oracle Database 10g Enterprise Edition 34288.77 Sybase Adaptive Server Enterprise 12.0
|
||||
2004-08-31 IBM DB2 UDB 8.1 429899.7 28 29 1184893.38 Oracle Database 10g Enterprise Edition 427760.83 Oracle Database 9i Enterprise Server v.9.2.0.1
|
||||
2004-09-29 Oracle Database 10g Standard Edition 51506.4 28 137 1184893.38 Oracle Database 10g Enterprise Edition 51226.96 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-10-15 Microsoft SQL Server 2000 Enterprise Edition SP3 32464.0 28 174 1184893.38 Oracle Database 10g Enterprise Edition 32377.17 Microsoft SQL Server 2000
|
||||
2004-10-15 Microsoft SQL Server 2000 Enterprise Edition SP3 115110.0 28 81 1184893.38 Oracle Database 10g Enterprise Edition 115025.75 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2004-10-19 Microsoft SQL Server 2000 Standard Edition SP3 17810.0 28 208 1184893.38 Oracle Database 10g Enterprise Edition 17659.53 Microsoft SQL Server 2000 Standard Edition
|
||||
2004-11-01 Microsoft SQL Server 2000 Enterprise Edition SP3 68010.0 28 118 1184893.38 Oracle Database 10g Enterprise Edition 67102.53 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2004-11-07 Microsoft SQL Server 2000 Enterprise Edition SP3 123027.0 28 76 1184893.38 Oracle Database 10g Enterprise Edition 121319.23 Microsoft SQL Server 2000
|
||||
2004-11-08 Oracle Database 10g Standard Edition 161217.4 28 63 1184893.38 Oracle Database 10g Enterprise Edition 156105.72 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2004-11-18 IBM DB2 UDB 8.2 3210540.63 29 1 3210540.63 IBM DB2 UDB 8.2 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2004-12-10 Microsoft SQL Server 2000 Enterprise Edition 26410.0 29 189 3210540.63 IBM DB2 UDB 8.2 24925.43 Microsoft SQL Server 2000
|
||||
2004-12-10 Microsoft SQL Server 2000 Enterprise Edition SP3 143367.0 29 70 3210540.63 IBM DB2 UDB 8.2 141138.44 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-01-25 IBM DB2 UDB 8.2 247650.0 29 46 3210540.63 IBM DB2 UDB 8.2 237869.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-01-25 IBM DB2 UDB 8.2 247650.0 29 46 3210540.63 IBM DB2 UDB 8.2 247650.0 IBM DB2 UDB 8.2
|
||||
2005-02-11 Microsoft SQL Server 2000 Enterprise Edition QFE 130623.0 30 81 3210540.63 IBM DB2 UDB 8.2 123027.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-02-11 Microsoft SQL Server 2000 Enterprise Edition SP3 71413.0 30 119 3210540.63 IBM DB2 UDB 8.2 71313.19 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-02-11 Microsoft SQL Server 2000 Enterprise Edition SP3 74298.0 30 115 3210540.63 IBM DB2 UDB 8.2 74206.27 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-02-14 Microsoft SQL Server 2000 Enterprise Edition SP3 67754.0 30 128 3210540.63 IBM DB2 UDB 8.2 67102.53 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2005-02-24 Microsoft SQL Server 2000 Workgroup Edition 28122.0 31 193 3210540.63 IBM DB2 UDB 8.2 26725.34 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-03-28 Microsoft SQL Server 2000 Enterprise Edition SP3 42432.0 31 164 3210540.63 IBM DB2 UDB 8.2 40621.26 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2005-04-20 Oracle Database 10g Enterprise Edition 1601784.98 31 2 3210540.63 IBM DB2 UDB 8.2 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2005-04-21 IBM DB2 UDB 8.2 150704.0 33 74 3210540.63 IBM DB2 UDB 8.2 143367.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-04-21 Microsoft SQL Server 2000 Enterprise Edition (SP3 w/QFE) 141504.0 33 76 3210540.63 IBM DB2 UDB 8.2 141138.44 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-04-21 Microsoft SQL Server 2000 Enterprise Edition SP4 187296.0 33 61 3210540.63 IBM DB2 UDB 8.2 181280.45 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-05-10 Microsoft SQL Server 2000 Enterprise Edition SP3 63646.0 33 137 3210540.63 IBM DB2 UDB 8.2 61564.5 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-05-31 IBM DB2 UDB 8.2 250975.0 33 47 3210540.63 IBM DB2 UDB 8.2 247650.0 IBM DB2 UDB 8.2
|
||||
2005-06-07 Microsoft SQL Server 2005 Enterprise Edition 64bit 1082203.0 34 4 3210540.63 IBM DB2 UDB 8.2 1025486.07 IBM DB2 UDB 8.1
|
||||
2005-06-24 Microsoft SQL Server 2000 Enterprise Edition SP3 65453.0 34 141 3210540.63 IBM DB2 UDB 8.2 63646.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-06-24 Microsoft SQL Server 2000 Enterprise Edition SP3 108574.0 34 101 3210540.63 IBM DB2 UDB 8.2 105687.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-06-24 Oracle Database 10g Enterprise Edition 322805.0 34 42 3210540.63 IBM DB2 UDB 8.2 309036.53 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-06-28 Microsoft SQL Server 2000 Enterprise Edition SP3 31253.0 34 200 3210540.63 IBM DB2 UDB 8.2 30231.37 Microsoft SQL Server 2000
|
||||
2005-07-01 Oracle Database 10g Enterprise Edition 327829.0 34 42 3210540.63 IBM DB2 UDB 8.2 322805.0 Oracle Database 10g Enterprise Edition
|
||||
2005-07-15 Microsoft SQL Server 2000 Enterprise Edition 64bit 332265.87 34 42 3210540.63 IBM DB2 UDB 8.2 327829.0 Oracle Database 10g Enterprise Edition
|
||||
2005-08-08 IBM DB2 UDB 8.2 197669.0 34 63 3210540.63 IBM DB2 UDB 8.2 197024.17 Oracle 8 Enterprise Edition v8.1.7.1
|
||||
2005-08-29 Microsoft SQL Server 2000 Enterprise Edition SP3 52742.0 34 159 3210540.63 IBM DB2 UDB 8.2 52671.3 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-09-14 Microsoft SQL Server 2005 Enterprise Edition 64bit 241300.0 34 54 3210540.63 IBM DB2 UDB 8.2 237869.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-09-26 Microsoft SQL Server 2005 Standard Edition x64 38622.0 35 183 3210540.63 IBM DB2 UDB 8.2 38386.24 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-09-30 Microsoft SQL Server 2005 Enterprise Edition 76214.0 36 131 3210540.63 IBM DB2 UDB 8.2 74298.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-09-30 Microsoft SQL Server 2005 Enterprise Edition 107010.0 36 109 3210540.63 IBM DB2 UDB 8.2 105687.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-09-30 Microsoft SQL Server 2005 Enterprise Edition 109633.0 36 107 3210540.63 IBM DB2 UDB 8.2 108574.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-09-30 Microsoft SQL Server 2005 Enterprise Edition 138845.0 36 88 3210540.63 IBM DB2 UDB 8.2 138362.03 Oracle Database 9i R2 Enterprise Edition
|
||||
2005-09-30 Microsoft SQL Server 2005 Enterprise Edition 202551.0 36 64 3210540.63 IBM DB2 UDB 8.2 197669.0 IBM DB2 UDB 8.2
|
||||
2005-10-17 Oracle Database 10g Enterprise Edition 203439.87 36 64 3210540.63 IBM DB2 UDB 8.2 202551.0 Microsoft SQL Server 2005 Enterprise Edition
|
||||
2005-10-24 Microsoft SQL Server 2005 Enterprise Edition x64 376045.0 37 39 3210540.63 IBM DB2 UDB 8.2 371044.22 Oracle Database 10g
|
||||
2005-10-28 Microsoft SQL Server 2000 Enterprise Edition SP4 188761.0 37 71 3210540.63 IBM DB2 UDB 8.2 187296.0 Microsoft SQL Server 2000 Enterprise Edition SP4
|
||||
2005-10-31 IBM DB2 UDB 8.2 221017.0 37 60 3210540.63 IBM DB2 UDB 8.2 220807.27 Oracle 8i Enterprise Edition v. 8.1.7
|
||||
2005-11-04 Microsoft SQL Server 2005 Enterprise Edition x64 206181.0 37 65 3210540.63 IBM DB2 UDB 8.2 203518.03 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2005-11-07 Microsoft SQL Server 2005 Enterprise Edition x64 251691.0 37 52 3210540.63 IBM DB2 UDB 8.2 250975.0 IBM DB2 UDB 8.2
|
||||
2005-11-22 Microsoft SQL Server 2005 Enterprise Edition 492307.0 37 28 3210540.63 IBM DB2 UDB 8.2 455818.2 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2005-11-28 Microsoft SQL Server 2005 Enterprise Edition SP1 1231433.0 38 3 3210540.63 IBM DB2 UDB 8.2 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2005-12-01 Microsoft SQL Server 2005 Enterprise Edition 85858.0 38 128 3210540.63 IBM DB2 UDB 8.2 85554.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2005-12-05 IBM DB2 UDB 8.2 236054.0 38 60 3210540.63 IBM DB2 UDB 8.2 234325.1 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-01-12 Microsoft SQL Server 2000 Enterprise Edition SP3 66543.0 38 160 3210540.63 IBM DB2 UDB 8.2 65453.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-01-18 Oracle Database 10g Enterprise Edition 254471.0 38 53 3210540.63 IBM DB2 UDB 8.2 252920.49 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-02-09 Microsoft SQL Server 2005 Workgroup Edition 28244.0 39 228 3210540.63 IBM DB2 UDB 8.2 28122.0 Microsoft SQL Server 2000 Workgroup Edition
|
||||
2006-02-14 IBM DB2 UDB 8.2 1025169.69 39 7 3210540.63 IBM DB2 UDB 8.2 1008144.49 Oracle Database 10g Enterprise Edition
|
||||
2006-02-22 Microsoft SQL Server 2005 Enterprise Edition x64 347854.0 39 45 3210540.63 IBM DB2 UDB 8.2 342746.25 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2006-03-07 IBM DB2 UDB 8.2 273520.0 39 55 3210540.63 IBM DB2 UDB 8.2 254471.0 Oracle Database 10g Enterprise Edition
|
||||
2006-03-09 Oracle Database 10g Enterprise Edition 200829.0 39 77 3210540.63 IBM DB2 UDB 8.2 197669.0 IBM DB2 UDB 8.2
|
||||
2006-03-20 Microsoft SQL Server 2005 Enterprise Edition 213986.0 40 72 3210540.63 IBM DB2 UDB 8.2 212511.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-03-20 Microsoft SQL Server 2005 Enterprise Edition x86 SP1 113628.0 40 118 3210540.63 IBM DB2 UDB 8.2 112740.87 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-03-21 Microsoft SQL Server 2005 Enterprise Edition x64 492307.0 40 30 3210540.63 IBM DB2 UDB 8.2 455818.2 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2006-03-27 Microsoft SQL Server 2005 Enterprise Edition Itanium 290644.0 41 56 3210540.63 IBM DB2 UDB 8.2 273520.0 IBM DB2 UDB 8.2
|
||||
2006-04-12 Microsoft SQL Server 2005 Standard Edition 57552.0 42 178 3210540.63 IBM DB2 UDB 8.2 57346.93 Oracle Database 9i Enterprise Edition v.9.0.1
|
||||
2006-04-26 Oracle Database 10g Enterprise Edition 792101.96 42 11 3210540.63 IBM DB2 UDB 8.2 786646.0 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2006-05-01 Microsoft SQL Server 2005 Enterprise Edition x64 125954.0 42 113 3210540.63 IBM DB2 UDB 8.2 123027.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-05-04 Microsoft SQL Server 2005 Enterprise Edition x86 SP1 110615.0 42 127 3210540.63 IBM DB2 UDB 8.2 109633.0 Microsoft SQL Server 2005 Enterprise Edition
|
||||
2006-05-08 Microsoft SQL Server 2005 Enterprise Edition x64 749839.0 42 15 3210540.63 IBM DB2 UDB 8.2 709220.08 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-05-22 Microsoft SQL Server 2005 Enterprise Edition x64 169360.0 42 91 3210540.63 IBM DB2 UDB 8.2 165218.71 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-06-12 Microsoft SQL Server 2005 Enterprise Edition x64 340243.0 42 50 3210540.63 IBM DB2 UDB 8.2 332265.87 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2006-06-23 Sybase Adaptive Server Enterprise v.12.5.4 81439.3 43 151 3210540.63 IBM DB2 UDB 8.2 80570.81 Oracle Database 10i Standard Edition
|
||||
2006-06-26 Microsoft SQL Server 2005 Enterprise Edition x64 140246.0 43 107 3210540.63 IBM DB2 UDB 8.2 140239.97 Sybase Adaptive Server Enterprise v12.5
|
||||
2006-06-30 Microsoft SQL Server 2005 Standard Edition 65833.0 43 178 3210540.63 IBM DB2 UDB 8.2 65453.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-07-18 Microsoft SQL Server 2005 Enterprise Edition Itanium 344928.0 43 49 3210540.63 IBM DB2 UDB 8.2 342746.25 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2006-07-24 IBM DB2 9 4016222.19 44 1 4016222.19 IBM DB2 9 3210540.63 IBM DB2 UDB 8.2
|
||||
2006-08-01 Oracle Database 10g Enterprise Edition 230569.0 44 73 4016222.19 IBM DB2 9 230533.0 Oracle Database 9i Enterprise Edition
|
||||
2006-09-13 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 147293.0 45 107 4016222.19 IBM DB2 9 143367.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-09-19 IBM DB2 9 314468.0 45 56 4016222.19 IBM DB2 9 309036.53 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-09-25 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 262989.0 45 64 4016222.19 IBM DB2 9 254471.0 Oracle Database 10g Enterprise Edition
|
||||
2006-10-19 Microsoft SQL Server 2005 Enterprise Edition 318407.0 45 56 4016222.19 IBM DB2 9 314468.0 IBM DB2 9
|
||||
2006-10-26 Oracle Database 10g R2 Enterprise Edition 359440.0 46 49 4016222.19 IBM DB2 9 347854.0 Microsoft SQL Server 2005 Enterprise Edition x64
|
||||
2006-11-09 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 139693.0 46 117 4016222.19 IBM DB2 9 139153.98 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2006-11-13 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 240737.0 46 74 4016222.19 IBM DB2 9 237869.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2006-11-14 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 222117.0 46 81 4016222.19 IBM DB2 9 221017.0 IBM DB2 UDB 8.2
|
||||
2006-11-30 Oracle Database 10g Enterprise Edition 1238579.0 46 4 4016222.19 IBM DB2 9 1231433.0 Microsoft SQL Server 2005 Enterprise Edition SP1
|
||||
2006-12-15 IBM DB2 9 331087.0 46 56 4016222.19 IBM DB2 9 327829.0 Oracle Database 10g Enterprise Edition
|
||||
2007-01-22 IBM DB2 9 4033378.0 46 1 4033378.0 IBM DB2 9 4016222.19 IBM DB2 9
|
||||
2007-02-13 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 138979.0 46 124 4033378.0 IBM DB2 9 138845.0 Microsoft SQL Server 2005 Enterprise Edition
|
||||
2007-02-27 Oracle Database 10g R2 Enterprise Edition w/Partitioning 4092799.0 47 1 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 4033378.0 IBM DB2 9
|
||||
2007-02-28 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 510822.0 47 36 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 492307.0 Microsoft SQL Server 2005 Enterprise Edition
|
||||
2007-03-09 Microsoft SQL Server 2005 Standard Edition 69564.0 47 184 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 69169.61 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2007-03-23 Microsoft SQL Server 2005 Enterprise Edition 520467.0 47 35 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 514034.72 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2007-03-25 IBM DB2 9 511342.0 47 37 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 510822.0 Microsoft SQL Server 2005 Enterprise Edition x64 SP1
|
||||
2007-03-27 Microsoft SQL Server 2005 Enterprise Edition x64 SP1 82774.0 47 170 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 82226.46 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2007-04-26 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 145180.0 48 121 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 143367.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2007-05-21 IBM DB2 Enterprise 9 1616162.0 49 5 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 1601784.98 Oracle Database 10g Enterprise Edition
|
||||
2007-06-08 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 126371.0 50 138 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 125954.0 Microsoft SQL Server 2005 Enterprise Edition x64
|
||||
2007-06-08 Oracle Database 10g Standard Edition One 100926.0 50 161 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 95163.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2007-06-11 Microsoft SQL Server 2005 Enterprise Edition Itanium 372140.0 50 54 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 371044.22 Oracle Database 10g
|
||||
2007-08-06 Oracle Database 10g Enterprise Edition 404462.0 50 50 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 403255.46 Oracle Database 9i R2 Enterprise Edition
|
||||
2007-09-05 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 251300.0 50 81 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 250975.0 IBM DB2 UDB 8.2
|
||||
2007-09-05 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 407079.0 50 50 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 404462.0 Oracle Database 10g Enterprise Edition
|
||||
2007-09-12 Oracle Database 11g Standard Edition One 102454.0 51 165 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 100926.0 Oracle Database 10g Standard Edition One
|
||||
2007-10-04 Oracle Database 10g R2 Enterprise Edition 236271.0 51 88 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 236054.0 IBM DB2 UDB 8.2
|
||||
2007-10-15 IBM DB2 9.5 Enterprise Edition 516752.0 52 37 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 514034.72 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2007-10-23 Microsoft SQL Server 2005 Enterprise Edition x64 841809.0 52 14 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 824164.53 Oracle Database 10g Enterprise Edition
|
||||
2007-10-30 Oracle Database 10g R2 Enterprise Edition w/Partitioning 2196268.0 52 5 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 1616162.0 IBM DB2 Enterprise 9
|
||||
2007-11-09 Oracle Database 10g Standard Edition One 273666.0 52 79 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 273520.0 IBM DB2 UDB 8.2
|
||||
2007-12-17 IBM DB2 9.1 1616162.0 53 6 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 1601784.98 IBM DB2 Enterprise 9
|
||||
2007-12-17 Oracle Database 10g Enterprise Edition 404462.0 53 55 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 403255.46 Oracle Database 9i R2 Enterprise Edition
|
||||
2008-01-07 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 275149.0 53 81 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 273666.0 Oracle Database 10g Standard Edition One
|
||||
2008-01-21 Oracle Database 10g R2 Enterprise Edition w/Partitioning 1245516.0 53 9 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 1238579.0 Oracle Database 10g Enterprise Edition
|
||||
2008-03-20 IBM DB2 9.5 Enterprise Edition 629159.0 53 34 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 609467.0 Oracle Database 10g Enterprise Edition
|
||||
2008-03-31 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 402234.0 53 61 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning 389434.4 Oracle Database 9i Enterprise Edition
|
||||
2008-06-10 IBM DB2 9.5 6085166.0 54 1 6085166.0 IBM DB2 9.5 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2008-06-11 IBM DB2 9.5 Enterprise Edition 629159.0 54 35 6085166.0 IBM DB2 9.5 609467.0 Oracle Database 10g Enterprise Edition
|
||||
2008-06-15 IBM DB2 9.5 6085166.0 54 1 6085166.0 IBM DB2 9.5 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2008-06-16 Oracle Database 11g Standard Edition One 97083.0 55 182 6085166.0 IBM DB2 9.5 95163.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2008-06-16 Sybase Adaptive Server Enterprise 15.0.3 276383.0 55 87 6085166.0 IBM DB2 9.5 275149.0 Microsoft SQL Server 2005 Enterprise Edition x64 SP2
|
||||
2008-07-14 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 471883.0 55 51 6085166.0 IBM DB2 9.5 455818.2 Fujitsu SymfoWARE Server Enterp. Ed. VLM 3.0
|
||||
2008-07-29 Sybase SQL Anywhere 11.0 20705.0 56 306 6085166.0 IBM DB2 9.5 20477.37 Microsoft SQL Server 2000 Standard Edition SP3
|
||||
2008-08-19 IBM DB2 ESE 9.5 1200632.0 57 14 6085166.0 IBM DB2 9.5 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2008-08-19 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 634825.0 57 37 6085166.0 IBM DB2 9.5 629159.0 IBM DB2 9.5 Enterprise Edition
|
||||
2008-09-15 Microsoft SQL Server 2005 Enterprise Edition x64 684508.0 57 33 6085166.0 IBM DB2 9.5 683575.0 Oracle Database 10g Enterprise Edition
|
||||
2008-11-17 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 579814.0 57 43 6085166.0 IBM DB2 9.5 577530.77 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2008-11-22 Oracle Database 10g R2 Enterprise Edition 1354086.0 57 11 6085166.0 IBM DB2 9.5 1245516.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2008-12-04 Oracle Database 10g R2 Enterprise Edition w/Partitioning 2382032.0 57 7 6085166.0 IBM DB2 9.5 2196268.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2009-01-16 Oracle Database 11g Standard Edition 639253.0 58 40 6085166.0 IBM DB2 9.5 634825.0 Microsoft SQL Server 2005 Enterprise Edition x64 SP2
|
||||
2009-02-20 Oracle Database 11g Standard Edition One 104492.0 58 187 6085166.0 IBM DB2 9.5 102667.42 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2009-03-30 Oracle Database 11g Standard Edition One 631766.0 58 42 6085166.0 IBM DB2 9.5 629159.0 IBM DB2 9.5 Enterprise Edition
|
||||
2009-05-21 Oracle Database 11g Standard Edition One 232002.0 58 114 6085166.0 IBM DB2 9.5 230569.0 Oracle Database 10g Enterprise Edition
|
||||
2009-11-04 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 7646486.0 59 1 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 6085166.0 IBM DB2 9.5
|
||||
2009-11-18 Oracle Database 11g Standard Edition One 239392.0 59 111 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 237869.0 Microsoft SQL Server 2000 Enterprise Edition
|
||||
2010-02-01 Microsoft SQL Server 2005 Enterprise Edition x64 SP2 661475.0 59 39 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 658277.74 Microsoft SQL Server 2000 Enterprise Edition 64bit
|
||||
2010-04-08 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 705652.0 60 34 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 688220.9 Microsoft SQL Server 2000
|
||||
2010-04-13 IBM DB2 9.5 1200011.0 60 18 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2010-05-11 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 803068.0 60 27 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 792101.96 Oracle Database 10g Enterprise Edition
|
||||
2010-06-22 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 1193472.0 60 19 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning 1184893.38 Oracle Database 10g Enterprise Edition
|
||||
2010-08-17 IBM DB2 9.7 10366254.0 62 1 10366254.0 IBM DB2 9.7 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning
|
||||
2010-08-17 Oracle Database 11g Release 2 Standard Ed One 290040.0 62 103 10366254.0 IBM DB2 9.7 276383.0 Sybase Adaptive Server Enterprise 15.0.3
|
||||
2010-08-30 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 1807347.0 62 11 10366254.0 IBM DB2 9.7 1616162.0 IBM DB2 9.1
|
||||
2010-11-16 IBM DB2 ESE 9.7 2308099.0 63 10 10366254.0 IBM DB2 9.7 2196268.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2010-12-02 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 30249688.0 64 1 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 10366254.0 IBM DB2 9.7
|
||||
2011-05-05 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 1024380.0 64 28 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1008144.49 Oracle Database 10g Enterprise Edition
|
||||
2011-05-23 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 1263599.0 64 18 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1245516.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2011-07-11 IBM DB2 ESE 9.7 3014684.0 64 10 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 2382032.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2011-11-15 Microsoft SQL Server 2005 Enterprise Edition x64 SP3 1207982.0 64 23 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1200632.0 IBM DB2 ESE 9.5
|
||||
2011-12-08 Oracle Database 11g Release 2 Standard Ed One 1053100.32 64 29 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1025486.07 IBM DB2 UDB 8.1
|
||||
2012-01-18 Oracle Database 11g R2 Enterprise Edition 4803718.0 65 6 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 4092799.0 Oracle Database 10g R2 Enterprise Edition w/Partitioning
|
||||
2012-04-11 IBM DB2 ESE 9.7 1503544.0 65 19 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1354086.0 Oracle Database 10g R2 Enterprise Edition
|
||||
2012-06-20 Oracle Database 11g R2 Enterprise Edition w/Partitioning 5055888.0 66 6 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 4803718.0 Oracle Database 11g R2 Enterprise Edition
|
||||
2012-09-26 Oracle Database 11g Standard Edition One 1609186.39 66 19 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1601784.98 Oracle Database 10g Enterprise Edition
|
||||
2013-02-22 IBM DB2 ESE 9.7 1320082.0 66 23 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 1263599.0 Microsoft SQL Server 2005 Enterprise Edition x64 SP3
|
||||
2013-03-26 Oracle 11g Release 2 Enterprise Edition with Oracle Partitioning 8552523.0 67 3 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 7646486.0 Oracle Database 11g Enterprise Edition w/RAC w/Partitioning
|
||||
2014-11-25 SQL Anywhere 16 112890.0 68 201 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 112740.87 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2017-05-08 SunjeSoft Goldilocks v3.1 Standard Edition 139909.0 69 180 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 139693.0 Microsoft SQL Server 2005 Enterprise Edition x64 SP1
|
||||
2018-11-19 SunjeSoft Goldilocks v3.1 Standard Edition 152330.0 69 170 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 151744.13 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2018-11-26 SunjeSoft Goldilocks v3.1 Standard Edition 76168.0 69 242 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 74298.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2018-11-26 SunjeSoft Goldilocks v3.1 Standard Edition 76172.0 69 241 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning 76168.0 SunjeSoft Goldilocks v3.1 Standard Edition
|
||||
2019-10-01 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 60880800.0 70 1 60880800.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 30249688.0 Oracle Database 11g R2 Enterprise Edition w/RAC w/Partitioning
|
||||
2019-10-14 SunjeSoft Goldilocks v3.1 Standard Edition 76168.0 70 244 60880800.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 74298.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2019-10-14 SunjeSoft Goldilocks v3.1 Standard Edition 114245.0 70 203 60880800.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 113628.0 Microsoft SQL Server 2005 Enterprise Edition x86 SP1
|
||||
2019-11-03 SunjeSoft Goldilocks v3.1 Standard Edition 152328.0 70 172 60880800.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 151744.13 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2020-05-19 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 707351007.0 70 1 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 60880800.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression
|
||||
2020-08-17 SunjeSoft Goldilocks v3.1 Standard Edition 380475.0 70 98 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 376045.0 Microsoft SQL Server 2005 Enterprise Edition x64
|
||||
2020-11-23 SunjeSoft Goldilocks v3.1 Standard Edition 76174.0 70 246 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 76172.0 SunjeSoft Goldilocks v3.1 Standard Edition
|
||||
2021-09-29 SunjeSoft Goldilocks v3.1 Standard Edition 144714.0 70 180 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 143367.0 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
2021-12-20 SunjeSoft Goldilocks v3.1 Standard Edition 101550.0 70 224 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 100926.0 Oracle Database 10g Standard Edition One
|
||||
2022-06-30 SunjeSoft Goldilocks v3.1 Standard Edition 190443.0 70 160 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 188761.0 Microsoft SQL Server 2000 Enterprise Edition SP4
|
||||
2022-09-07 SunjeSoft Goldilocks v3.1 Standard Edition 507802.0 70 80 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression 492307.0 Microsoft SQL Server 2005 Enterprise Edition
|
||||
2023-03-24 Tencent TDSQL v10.3 Enterprise Pro Edition with Partitioning and Physical Replication 814854791.0 71 1 814854791.0 Tencent TDSQL v10.3 Enterprise Pro Edition with Partitioning and Physical Replication 707351007.0 OceanBase v2.2 Enterprise Edition with Partitioning, Horizontal Scalability and Advanced Compression
|
||||
2023-10-02 IBM DB2 11.5.8 Advanced Edition 279185.0 72 123 814854791.0 Tencent TDSQL v10.3 Enterprise Pro Edition with Partitioning and Physical Replication 276383.0 Sybase Adaptive Server Enterprise 15.0.3
|
||||
2024-02-26 SunjeSoft Goldilocks v3.1 Standard Edition 50768.0 72 300 814854791.0 Tencent TDSQL v10.3 Enterprise Pro Edition with Partitioning and Physical Replication 50666.11 Microsoft SQL Server 2000 Enterprise Edition SP3
|
||||
39
external/duckdb/test/sql/window/test_tpcds_q49.test
vendored
Normal file
39
external/duckdb/test/sql/window/test_tpcds_q49.test
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# name: test/sql/window/test_tpcds_q49.test
|
||||
# description: TPC-DS Q49 bug fix for multi-sort window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
create table wintest( item integer, return_ratio numeric, currency_ratio numeric)
|
||||
|
||||
statement ok
|
||||
insert into wintest values (7539 ,0.590000 , 0.590000), (3337 ,0.626506 , 0.626506), (15597 ,0.661972 , 0.661972), (2915 ,0.698630 , 0.698630), (11933 ,0.717172 , 0.717172), (483 ,0.800000 , 0.800000), (85 ,0.857143 , 0.857143), (97 ,0.903614 , 0.903614), (117 ,0.925000 , 0.925000), (5299 ,0.927083 , 0.927083), (10055 ,0.945652 , 0.945652), (4231 ,0.977778 , 0.977778), (5647 ,0.987805 , 0.987805), (8679 ,0.988764 , 0.988764), (10323 ,0.977778 , 1.111111), (3305 ,0.737500 , 1.293860)
|
||||
|
||||
query III
|
||||
SELECT item, rank() OVER (ORDER BY return_ratio) AS return_rank, rank() OVER (ORDER BY currency_ratio) AS currency_rank FROM wintest order by item
|
||||
----
|
||||
85 8 7
|
||||
97 9 8
|
||||
117 10 9
|
||||
483 7 6
|
||||
2915 4 4
|
||||
3305 6 16
|
||||
3337 2 2
|
||||
4231 13 12
|
||||
5299 11 10
|
||||
5647 15 13
|
||||
7539 1 1
|
||||
8679 16 14
|
||||
10055 12 11
|
||||
10323 13 15
|
||||
11933 5 5
|
||||
15597 3 3
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
47
external/duckdb/test/sql/window/test_value_orderby.test
vendored
Normal file
47
external/duckdb/test/sql/window/test_value_orderby.test
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# name: test/sql/window/test_value_orderby.test
|
||||
# description: Secondary orderings of XXX_VALUE functions.
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query IIIII
|
||||
SELECT
|
||||
i,
|
||||
(i * 29) % 11 AS outside,
|
||||
first_value(i ORDER BY i DESC) OVER w,
|
||||
last_value(i ORDER BY i DESC) OVER w,
|
||||
nth_value(i, 2 ORDER BY i DESC) OVER w,
|
||||
FROM range(10) tbl(i)
|
||||
WINDOW w AS (
|
||||
ORDER BY (i * 29) % 11
|
||||
ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING
|
||||
)
|
||||
ORDER BY 2
|
||||
----
|
||||
0 0 8 0 5
|
||||
8 1 8 0 7
|
||||
5 2 8 0 7
|
||||
2 3 8 0 7
|
||||
7 5 9 1 8
|
||||
4 6 9 1 7
|
||||
1 7 9 1 7
|
||||
9 8 9 1 7
|
||||
6 9 9 1 6
|
||||
3 10 9 1 6
|
||||
|
||||
# Frame larger than data
|
||||
query I
|
||||
with IDS as (
|
||||
select * as idx from generate_series(1,4)
|
||||
),DATA as (
|
||||
select *, (case when idx != 3 then idx * 1.0 else NULL end) as value from IDS
|
||||
)
|
||||
SELECT
|
||||
last(value ORDER BY idx IGNORE NULLS) OVER (ORDER BY idx ROWS BETWEEN UNBOUNDED PRECEDING AND 0 FOLLOWING)
|
||||
FROM DATA
|
||||
----
|
||||
1.0
|
||||
2.0
|
||||
2.0
|
||||
4.0
|
||||
18
external/duckdb/test/sql/window/test_volatile_independence.test
vendored
Normal file
18
external/duckdb/test/sql/window/test_volatile_independence.test
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# name: test/sql/window/test_volatile_independence.test
|
||||
# description: Window Sharing should distiguish identical volatile expressions
|
||||
# group: [window]
|
||||
|
||||
# With chunk-level window parallelism, the order of evaluation changes with vector size
|
||||
require vector_size 2048
|
||||
|
||||
set seed 0.8675309
|
||||
|
||||
query II
|
||||
SELECT
|
||||
list(random()) OVER (ORDER BY id),
|
||||
max(random()) OVER (ORDER BY id)
|
||||
FROM range(3) t(id);
|
||||
----
|
||||
[0.5232026142836782] 0.985522684201432
|
||||
[0.5232026142836782, 0.47754610640283557] 0.985522684201432
|
||||
[0.5232026142836782, 0.47754610640283557, 0.6947716273694302] 0.985522684201432
|
||||
29
external/duckdb/test/sql/window/test_wide_orderby.test
vendored
Normal file
29
external/duckdb/test/sql/window/test_wide_orderby.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/sql/window/test_wide_orderby.test
|
||||
# description: Verify 32 and 64 bit tree construction
|
||||
# group: [window]
|
||||
|
||||
foreach forced false true
|
||||
|
||||
# This forces 64 bit trees when true
|
||||
statement ok
|
||||
PRAGMA debug_force_external=${forced}
|
||||
|
||||
# SelectNth
|
||||
statement ok
|
||||
SELECT last_value(i ORDER BY i DESC) OVER w AS crash
|
||||
FROM range(5_000) tbl(i)
|
||||
WINDOW w AS (ORDER BY i ASC)
|
||||
|
||||
# Rank
|
||||
statement ok
|
||||
SELECT rank(ORDER BY i DESC) OVER w AS crash
|
||||
FROM range(5_000) tbl(i)
|
||||
WINDOW w AS (ORDER BY i ASC)
|
||||
|
||||
# Peer End
|
||||
statement ok
|
||||
SELECT cume_dist(ORDER BY i DESC) OVER w AS crash
|
||||
FROM range(5_000) tbl(i)
|
||||
WINDOW w AS (ORDER BY i ASC)
|
||||
|
||||
endloop
|
||||
23
external/duckdb/test/sql/window/test_window_1367.test_slow
vendored
Normal file
23
external/duckdb/test/sql/window/test_window_1367.test_slow
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# name: test/sql/window/test_window_1367.test_slow
|
||||
# description: Performance test from Issue #1367
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table data(id integer, value integer, primary key(id));
|
||||
|
||||
statement ok
|
||||
insert into data (id, value)
|
||||
select id, random() * 100000 as value
|
||||
from (select range as id from range(0, 1000000)) ids;
|
||||
|
||||
query I
|
||||
select count(*)
|
||||
from (
|
||||
select value, row_number() over(order by id)
|
||||
from data
|
||||
) w;
|
||||
----
|
||||
1000000
|
||||
36
external/duckdb/test/sql/window/test_window_binding.test
vendored
Normal file
36
external/duckdb/test/sql/window/test_window_binding.test
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# name: test/sql/window/test_window_binding.test
|
||||
# description: Test errors in binding window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER)
|
||||
|
||||
# we use columns here that are not part of the table
|
||||
statement error
|
||||
SELECT MIN(a) OVER (PARTITION BY i ORDER BY i) FROM integers
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT MIN(i) OVER (PARTITION BY a ORDER BY i) FROM integers
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT MIN(i) OVER (PARTITION BY i ORDER BY a) FROM integers
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT MIN(i) OVER (PARTITION BY i, a ORDER BY i) FROM integers
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT MIN(i) OVER (PARTITION BY i ORDER BY i, a) FROM integers
|
||||
----
|
||||
|
||||
# now we only use the "proper" columns
|
||||
query I
|
||||
SELECT MIN(i) OVER (PARTITION BY i ORDER BY i) FROM integers
|
||||
----
|
||||
|
||||
84
external/duckdb/test/sql/window/test_window_binding_ctes.test
vendored
Normal file
84
external/duckdb/test/sql/window/test_window_binding_ctes.test
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
# name: test/sql/window/test_window_binding_ctes.test
|
||||
# description: Test binding of named window functions in CTEs
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# named window clause
|
||||
query II
|
||||
select i, lag(i) over named_window from (values (1), (2), (3)) as t (i) window named_window as (order by i);
|
||||
----
|
||||
1 NULL
|
||||
2 1
|
||||
3 2
|
||||
|
||||
# named window clause in CTE
|
||||
query II
|
||||
with subquery as (select i, lag(i) over named_window from (values (1), (2), (3)) as t (i) window named_window as (order by i)) select * from subquery;
|
||||
----
|
||||
1 NULL
|
||||
2 1
|
||||
3 2
|
||||
|
||||
# named window clause in subquery
|
||||
query II
|
||||
select * from (select i, lag(i) over named_window from (values (1), (2), (3)) as t (i) window named_window as (order by i)) t1;
|
||||
----
|
||||
1 NULL
|
||||
2 1
|
||||
3 2
|
||||
|
||||
# named window clause in view
|
||||
statement ok
|
||||
CREATE VIEW v1 AS select i, lag(i) over named_window from (values (1), (2), (3)) as t (i) window named_window as (order by i);
|
||||
|
||||
query II
|
||||
select * from v1;
|
||||
----
|
||||
1 NULL
|
||||
2 1
|
||||
3 2
|
||||
|
||||
# same window clause name multiple times but in different subqueries
|
||||
query IIII
|
||||
SELECT * FROM (SELECT i, lag(i) OVER named_window FROM ( VALUES (1), (2), (3)) AS t (i) window named_window AS ( ORDER BY i)) t1, (SELECT i, lag(i) OVER named_window FROM ( VALUES (1), (2), (3)) AS t (i) window named_window AS ( ORDER BY i)) t2 ORDER BY 1, 2, 3, 4;
|
||||
----
|
||||
1 NULL 1 NULL
|
||||
1 NULL 2 1
|
||||
1 NULL 3 2
|
||||
2 1 1 NULL
|
||||
2 1 2 1
|
||||
2 1 3 2
|
||||
3 2 1 NULL
|
||||
3 2 2 1
|
||||
3 2 3 2
|
||||
|
||||
# we cannot use named window specifications of the main query inside CTEs
|
||||
statement error
|
||||
WITH subquery AS (SELECT i, lag(i) OVER named_window FROM ( VALUES (1), (2), (3)) AS t (i)) SELECT * FROM subquery window named_window AS ( ORDER BY i);
|
||||
----
|
||||
|
||||
# duplicate window clause name
|
||||
statement error
|
||||
select i, lag(i) over named_window from (values (1), (2), (3)) as t (i) window named_window as (order by i), named_window as (order by j);
|
||||
----
|
||||
|
||||
# window specs are locally scoped.
|
||||
statement ok
|
||||
CREATE TABLE a (id INT);
|
||||
|
||||
statement ok
|
||||
WITH
|
||||
cte_a AS (
|
||||
SELECT *
|
||||
FROM a
|
||||
WINDOW my_window AS ()
|
||||
),
|
||||
cte_b AS (
|
||||
SELECT *
|
||||
FROM a
|
||||
WINDOW my_window AS ()
|
||||
)
|
||||
SELECT *
|
||||
FROM cte_a CROSS JOIN cte_b;
|
||||
65
external/duckdb/test/sql/window/test_window_bool.test
vendored
Normal file
65
external/duckdb/test/sql/window/test_window_bool.test
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# name: test/sql/window/test_window_bool.test
|
||||
# description: Test window functions with booleans
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# bool as group
|
||||
statement ok
|
||||
create table a as select range%2==0 j, range::integer AS i from range(1, 5, 1)
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over () from a order by 1,2
|
||||
----
|
||||
False 1 10
|
||||
False 3 10
|
||||
True 2 10
|
||||
True 4 10
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j) from a order by 1,2
|
||||
----
|
||||
False 1 4
|
||||
False 3 4
|
||||
True 2 6
|
||||
True 4 6
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j order by i) from a order by 1,2
|
||||
----
|
||||
False 1 1
|
||||
False 3 4
|
||||
True 2 2
|
||||
True 4 6
|
||||
|
||||
statement ok
|
||||
drop table a
|
||||
|
||||
# bool as input to aggregate
|
||||
statement ok
|
||||
create table a as select range%2 j, range%3==0 AS i from range(1, 5, 1)
|
||||
|
||||
query IIII
|
||||
select j, i, bool_and(i) over (), bool_or(i) over () from a order by 1,2
|
||||
----
|
||||
0 False False True
|
||||
0 False False True
|
||||
1 False False True
|
||||
1 True False True
|
||||
|
||||
query IIII
|
||||
select j, i, bool_and(i) over (partition by j), bool_or(i) over (partition by j) from a order by 1,2
|
||||
----
|
||||
0 False False False
|
||||
0 False False False
|
||||
1 False False True
|
||||
1 True False True
|
||||
|
||||
query IIIII
|
||||
select j, i, bool_and(not i) over (partition by j order by i), bool_and(i) over (partition by j order by i), bool_or(i) over (partition by j order by i) from a order by 1,2
|
||||
----
|
||||
0 False True False False
|
||||
0 False True False False
|
||||
1 False True False False
|
||||
1 True False False True
|
||||
84
external/duckdb/test/sql/window/test_window_clause.test
vendored
Normal file
84
external/duckdb/test/sql/window/test_window_clause.test
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
# name: test/sql/window/test_window_clause.test
|
||||
# description: Test window clauses and overrides
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table integers as select range i from range(0,16);
|
||||
|
||||
# if a window clause is not being read, these would return 16
|
||||
query IIII
|
||||
select max(base), max(referenced), sum(refined), sum(unrefined) from (
|
||||
select
|
||||
row_number() over w AS base,
|
||||
row_number() over (w) as referenced,
|
||||
sum(i % 4) over (w rows between 1 preceding and 1 following) AS refined,
|
||||
sum(i % 4) over (rows between 1 preceding and 1 following) AS unrefined
|
||||
from integers
|
||||
WINDOW w AS (partition by i // 4 order by i % 4)
|
||||
) q;
|
||||
----
|
||||
4 4 60 69
|
||||
|
||||
#
|
||||
# Clause overrides
|
||||
#
|
||||
query IIII
|
||||
select
|
||||
x, y,
|
||||
count(*) over (partition by y order by x),
|
||||
count(*) over (w order by x)
|
||||
from (values (1, 1), (2, 1), (3, 2), (4, 2)) as t (x, y)
|
||||
window w as (partition by y)
|
||||
order by x
|
||||
----
|
||||
1 1 1 1
|
||||
2 1 2 2
|
||||
3 2 1 1
|
||||
4 2 2 2
|
||||
|
||||
statement error
|
||||
select
|
||||
x, y,
|
||||
count(*) over (partition by y order by x),
|
||||
count(*) over (w order by x)
|
||||
from (values (1, 1), (2, 1), (3, 2), (4, 2)) as t (x, y)
|
||||
window w as (partition by y order by x desc)
|
||||
order by x
|
||||
----
|
||||
Cannot override ORDER BY clause of window "w"
|
||||
|
||||
statement error
|
||||
select
|
||||
x, y,
|
||||
count(*) over (partition by y order by x),
|
||||
count(*) over (w partition by y)
|
||||
from (values (1, 1), (2, 1), (3, 2), (4, 2)) as t (x, y)
|
||||
window w as (partition by x)
|
||||
order by x
|
||||
----
|
||||
Cannot override PARTITION BY clause of window "w"
|
||||
|
||||
statement error
|
||||
select i, sum(i) over (w) as smoothed
|
||||
from integers
|
||||
window w AS (order by i rows between 1 preceding and 1 following)
|
||||
order by i;
|
||||
----
|
||||
frame clause
|
||||
|
||||
# Case insensitivity
|
||||
statement error
|
||||
SELECT sum(1) over cumulativeSum
|
||||
FROM integers
|
||||
WINDOW cumulativeSum AS (),
|
||||
cumulativesum AS (order by i rows between 1 preceding and 1 following);
|
||||
----
|
||||
already defined
|
||||
|
||||
statement ok
|
||||
SELECT sum(i) over cumulativeSum
|
||||
FROM integers
|
||||
WINDOW cumulativeSum AS ();
|
||||
311
external/duckdb/test/sql/window/test_window_constant_aggregate.test
vendored
Normal file
311
external/duckdb/test/sql/window/test_window_constant_aggregate.test
vendored
Normal file
@@ -0,0 +1,311 @@
|
||||
# name: test/sql/window/test_window_constant_aggregate.test
|
||||
# description: Test "constant" aggregation (single result for each partition)
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Mix of constant/non-constant aggregate (sum and lead over same OVER clause)
|
||||
query IIII
|
||||
SELECT part, id, sum(val) OVER(PARTITION BY part ORDER BY id), lead(val) OVER(PARTITION BY part ORDER BY id)
|
||||
FROM (SELECT range AS id, range % 5 AS part, range AS val FROM range(13)) t
|
||||
ORDER BY ALL;
|
||||
----
|
||||
0 0 0 5
|
||||
0 5 5 10
|
||||
0 10 15 NULL
|
||||
1 1 1 6
|
||||
1 6 7 11
|
||||
1 11 18 NULL
|
||||
2 2 2 7
|
||||
2 7 9 12
|
||||
2 12 21 NULL
|
||||
3 3 3 8
|
||||
3 8 11 NULL
|
||||
4 4 4 9
|
||||
4 9 13 NULL
|
||||
|
||||
# Constant aggregate with non-simple_update
|
||||
query III
|
||||
SELECT part, id, list_sort(list(val) OVER(PARTITION BY part))
|
||||
FROM (SELECT range AS id, range % 5 AS part, range AS val FROM range(13)) t
|
||||
ORDER BY ALL;
|
||||
----
|
||||
0 0 [0, 5, 10]
|
||||
0 5 [0, 5, 10]
|
||||
0 10 [0, 5, 10]
|
||||
1 1 [1, 6, 11]
|
||||
1 6 [1, 6, 11]
|
||||
1 11 [1, 6, 11]
|
||||
2 2 [2, 7, 12]
|
||||
2 7 [2, 7, 12]
|
||||
2 12 [2, 7, 12]
|
||||
3 3 [3, 8]
|
||||
3 8 [3, 8]
|
||||
4 4 [4, 9]
|
||||
4 9 [4, 9]
|
||||
|
||||
# Constant aggregate with not-nicely-aligned partitions (e.g. partitions are 73, 75, 77, 79, 81, 83, ... rows)
|
||||
query III
|
||||
SELECT part, min(const) AS lo, max(const) AS hi
|
||||
FROM (
|
||||
SELECT part, sum(val) OVER(PARTITION BY part) as const
|
||||
FROM (
|
||||
(SELECT 1 AS part, range AS val FROM range(73))
|
||||
UNION ALL
|
||||
(SELECT 2 AS part, range AS val FROM range(75))
|
||||
UNION ALL
|
||||
(SELECT 3 AS part, range AS val FROM range(77))
|
||||
UNION ALL
|
||||
(SELECT 4 AS part, range AS val FROM range(79))
|
||||
UNION ALL
|
||||
(SELECT 5 AS part, range AS val FROM range(81))
|
||||
UNION ALL
|
||||
(SELECT 6 AS part, range AS val FROM range(83))
|
||||
) u
|
||||
) t
|
||||
GROUP BY ALL
|
||||
ORDER BY ALL
|
||||
;
|
||||
----
|
||||
1 2628 2628
|
||||
2 2775 2775
|
||||
3 2926 2926
|
||||
4 3081 3081
|
||||
5 3240 3240
|
||||
6 3403 3403
|
||||
|
||||
# Constant aggregate with large partitions (> vector size), also not nicely-aligned
|
||||
query III
|
||||
SELECT part, min(const) AS lo, max(const) AS hi
|
||||
FROM (
|
||||
SELECT part, sum(val) OVER(PARTITION BY part) AS const
|
||||
FROM (
|
||||
SELECT part, val
|
||||
FROM (
|
||||
(SELECT range as part, random() AS val FROM range(10)) r
|
||||
CROSS JOIN
|
||||
range(3000)
|
||||
) p
|
||||
) t
|
||||
) w
|
||||
GROUP BY ALL
|
||||
HAVING lo <> hi
|
||||
ORDER BY ALL
|
||||
;
|
||||
----
|
||||
|
||||
statement ok
|
||||
CREATE TABLE issue7353 (
|
||||
Season VARCHAR,
|
||||
Medal VARCHAR,
|
||||
Sex VARCHAR,
|
||||
Ct INT,
|
||||
Depth INT
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO issue7353 (Season, Medal, Sex, Ct, Depth) VALUES
|
||||
(NULL, NULL, NULL, 271116, 0),
|
||||
('Summer', NULL, NULL, 222552, 1),
|
||||
('Winter', NULL, NULL, 48564, 1),
|
||||
('Summer', 'NA', NULL, 188464, 2),
|
||||
('Summer', 'Gold', NULL, 11459, 2),
|
||||
('Winter', 'NA', NULL, 42869, 2),
|
||||
('Summer', 'Bronze', NULL, 11409, 2),
|
||||
('Winter', 'Bronze', NULL, 1886, 2),
|
||||
('Winter', 'Gold', NULL, 1913, 2),
|
||||
('Winter', 'Silver', NULL, 1896, 2),
|
||||
('Summer', 'Silver', NULL, 11220, 2),
|
||||
('Summer', 'NA', 'M', 138463, 3),
|
||||
('Summer', 'Gold', 'M', 8319, 3),
|
||||
('Winter', 'NA', 'F', 13268, 3),
|
||||
('Winter', 'NA', 'M', 29601, 3),
|
||||
('Summer', 'NA', 'F', 50001, 3),
|
||||
('Summer', 'Bronze', 'M', 8235, 3),
|
||||
('Winter', 'Bronze', 'M', 1289, 3),
|
||||
('Winter', 'Gold', 'M', 1306, 3),
|
||||
('Winter', 'Silver', 'M', 1289, 3),
|
||||
('Summer', 'Gold', 'F', 3140, 3),
|
||||
('Summer', 'Silver', 'M', 8092, 3),
|
||||
('Summer', 'Bronze', 'F', 3174, 3),
|
||||
('Summer', 'Silver', 'F', 3128, 3),
|
||||
('Winter', 'Bronze', 'F', 597, 3),
|
||||
('Winter', 'Gold', 'F', 607, 3),
|
||||
('Winter', 'Silver', 'F', 607, 3);
|
||||
|
||||
# Calculate the max at the level Depth=1 and add to every row
|
||||
statement ok
|
||||
PRAGMA default_null_order='NULLS LAST';
|
||||
|
||||
query IIIIII
|
||||
SELECT *, max(Ct) FILTER (WHERE Depth=1) OVER (PARTITION BY Season) as value_depth1
|
||||
from issue7353
|
||||
order by all;
|
||||
----
|
||||
Summer Bronze F 3174 3 222552
|
||||
Summer Bronze M 8235 3 222552
|
||||
Summer Bronze NULL 11409 2 222552
|
||||
Summer Gold F 3140 3 222552
|
||||
Summer Gold M 8319 3 222552
|
||||
Summer Gold NULL 11459 2 222552
|
||||
Summer NA F 50001 3 222552
|
||||
Summer NA M 138463 3 222552
|
||||
Summer NA NULL 188464 2 222552
|
||||
Summer Silver F 3128 3 222552
|
||||
Summer Silver M 8092 3 222552
|
||||
Summer Silver NULL 11220 2 222552
|
||||
Summer NULL NULL 222552 1 222552
|
||||
Winter Bronze F 597 3 48564
|
||||
Winter Bronze M 1289 3 48564
|
||||
Winter Bronze NULL 1886 2 48564
|
||||
Winter Gold F 607 3 48564
|
||||
Winter Gold M 1306 3 48564
|
||||
Winter Gold NULL 1913 2 48564
|
||||
Winter NA F 13268 3 48564
|
||||
Winter NA M 29601 3 48564
|
||||
Winter NA NULL 42869 2 48564
|
||||
Winter Silver F 607 3 48564
|
||||
Winter Silver M 1289 3 48564
|
||||
Winter Silver NULL 1896 2 48564
|
||||
Winter NULL NULL 48564 1 48564
|
||||
NULL NULL NULL 271116 0 NULL
|
||||
|
||||
# Test ORDER BY handling
|
||||
query III
|
||||
SELECT
|
||||
i // 10 AS p,
|
||||
i,
|
||||
STRING_AGG(i, ',' ORDER BY i DESC) OVER(PARTITION BY p) AS c
|
||||
FROM range(20) tbl(i)
|
||||
ORDER BY ALL
|
||||
----
|
||||
0 0 9,8,7,6,5,4,3,2,1,0
|
||||
0 1 9,8,7,6,5,4,3,2,1,0
|
||||
0 2 9,8,7,6,5,4,3,2,1,0
|
||||
0 3 9,8,7,6,5,4,3,2,1,0
|
||||
0 4 9,8,7,6,5,4,3,2,1,0
|
||||
0 5 9,8,7,6,5,4,3,2,1,0
|
||||
0 6 9,8,7,6,5,4,3,2,1,0
|
||||
0 7 9,8,7,6,5,4,3,2,1,0
|
||||
0 8 9,8,7,6,5,4,3,2,1,0
|
||||
0 9 9,8,7,6,5,4,3,2,1,0
|
||||
1 10 19,18,17,16,15,14,13,12,11,10
|
||||
1 11 19,18,17,16,15,14,13,12,11,10
|
||||
1 12 19,18,17,16,15,14,13,12,11,10
|
||||
1 13 19,18,17,16,15,14,13,12,11,10
|
||||
1 14 19,18,17,16,15,14,13,12,11,10
|
||||
1 15 19,18,17,16,15,14,13,12,11,10
|
||||
1 16 19,18,17,16,15,14,13,12,11,10
|
||||
1 17 19,18,17,16,15,14,13,12,11,10
|
||||
1 18 19,18,17,16,15,14,13,12,11,10
|
||||
1 19 19,18,17,16,15,14,13,12,11,10
|
||||
|
||||
# Test hash group with two partitions and blocks
|
||||
statement ok
|
||||
pragma threads=2
|
||||
|
||||
loop i 0 20
|
||||
|
||||
query III
|
||||
with table_1 AS (
|
||||
SELECT
|
||||
'fb30cf47-6f6b-42ef-dec2-3f984479a2aa'::uuid AS id,
|
||||
unnest(generate_series(
|
||||
'2024-04-01'::date,
|
||||
'2025-03-01'::date,
|
||||
interval '1 month'
|
||||
)) AS date
|
||||
UNION ALL BY NAME
|
||||
SELECT
|
||||
'7d1cc557-2d45-6900-a1ed-b2c64f5d9200'::uuid AS id,
|
||||
unnest(generate_series(
|
||||
'2024-02-01'::date,
|
||||
'2025-01-01'::date,
|
||||
interval '1 month'
|
||||
)) AS date
|
||||
), table_2 AS (
|
||||
SELECT
|
||||
'fb30cf47-6f6b-42ef-dec2-3f984479a2aa'::uuid AS id,
|
||||
unnest(generate_series(
|
||||
'2024-04-01'::date,
|
||||
'2025-03-01'::date,
|
||||
interval '1 month'
|
||||
)) AS date,
|
||||
1 AS value
|
||||
UNION ALL BY NAME
|
||||
SELECT
|
||||
'7d1cc557-2d45-6900-a1ed-b2c64f5d9200'::uuid AS id,
|
||||
unnest(generate_series(
|
||||
'2022-12-01'::date,
|
||||
'2023-12-01'::date,
|
||||
interval '1 month'
|
||||
)) AS date,
|
||||
1 AS value
|
||||
), output AS (
|
||||
SELECT
|
||||
table_1.id,
|
||||
table_1.date,
|
||||
sum(table_2.value) over (
|
||||
PARTITION BY table_1.id
|
||||
ORDER BY table_1.date ASC
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) AS test_sum,
|
||||
FROM table_1
|
||||
LEFT JOIN table_2
|
||||
ON table_1.id = table_2.id
|
||||
AND table_1.date = table_2.date
|
||||
)
|
||||
SELECT * FROM output
|
||||
ORDER BY id DESC, date DESC;
|
||||
----
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2025-03-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2025-02-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2025-01-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-12-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-11-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-10-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-09-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-08-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-07-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-06-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-05-01 00:00:00 12
|
||||
fb30cf47-6f6b-42ef-dec2-3f984479a2aa 2024-04-01 00:00:00 12
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2025-01-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-12-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-11-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-10-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-09-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-08-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-07-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-06-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-05-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-04-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-03-01 00:00:00 NULL
|
||||
7d1cc557-2d45-6900-a1ed-b2c64f5d9200 2024-02-01 00:00:00 NULL
|
||||
|
||||
endloop
|
||||
|
||||
# Test implicit ordering for aggregates
|
||||
loop i 0 20
|
||||
|
||||
query I
|
||||
with repro2 AS (
|
||||
SELECT range // 59 AS id, random() AS value
|
||||
FROM range(1475)
|
||||
), X AS (
|
||||
SELECT
|
||||
list(value) OVER (
|
||||
PARTITION BY id
|
||||
ORDER BY value
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
) AS values
|
||||
FROM repro2
|
||||
)
|
||||
select count(*)
|
||||
from X
|
||||
where values[1] != list_aggregate(values, 'min')
|
||||
----
|
||||
0
|
||||
|
||||
endloop
|
||||
77
external/duckdb/test/sql/window/test_window_cse.test
vendored
Normal file
77
external/duckdb/test/sql/window/test_window_cse.test
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
# name: test/sql/window/test_window_cse.test
|
||||
# description: Test window Common Subexpression Elimination
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA explain_output = PHYSICAL_ONLY;
|
||||
|
||||
set seed 0.8675309
|
||||
|
||||
statement ok
|
||||
CREATE TABLE eventlog AS
|
||||
SELECT ts,
|
||||
CHR((RANDOM() * 3 + 65)::INTEGER) AS activity_name,
|
||||
(RANDOM() * 100)::INTEGER AS case_id
|
||||
FROM generate_series('2023-01-01'::TIMESTAMP, '2023-02-01'::TIMESTAMP, INTERVAL 1 HOUR) tbl(ts);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW cse AS
|
||||
WITH t AS (SELECT
|
||||
string_agg(activity_name, ',' order by ts asc, activity_name) as trace,
|
||||
1 as cnt
|
||||
from
|
||||
eventlog
|
||||
group by case_id
|
||||
)
|
||||
SELECT
|
||||
trace,
|
||||
sum(cnt) as cnt_trace,
|
||||
sum(cnt_trace) over () as cnt_total,
|
||||
sum(cnt) / sum(cnt_trace) over () as rel,
|
||||
sum(cnt_trace) over (
|
||||
order by cnt_trace desc
|
||||
ROWS between UNBOUNDED PRECEDING and CURRENT ROW)
|
||||
/ sum(cnt_trace) over ()
|
||||
as rel
|
||||
from t
|
||||
group by trace
|
||||
order by cnt_trace desc
|
||||
|
||||
# CSE should produce only one window operator
|
||||
query II
|
||||
EXPLAIN FROM cse;
|
||||
----
|
||||
physical_plan <REGEX>:.*WINDOW.*
|
||||
|
||||
query II
|
||||
EXPLAIN FROM cse;
|
||||
----
|
||||
physical_plan <!REGEX>:.*WINDOW.*WINDOW.*
|
||||
|
||||
# CSE should produce only two computations of sum(cnt_trace)
|
||||
query II
|
||||
EXPLAIN FROM cse;
|
||||
----
|
||||
physical_plan <REGEX>:.*sum\(cnt_trace\).*sum\(cnt_trace\).*
|
||||
|
||||
query II
|
||||
EXPLAIN FROM cse;
|
||||
----
|
||||
physical_plan <!REGEX>:.*sum\(cnt_trace\).*sum\(cnt_trace\).*sum\(cnt_trace\).*
|
||||
|
||||
|
||||
statement ok
|
||||
CREATE VIEW noncse AS
|
||||
SELECT
|
||||
quantile(x, 0.3) over() as q3,
|
||||
quantile(x, 0.7) over() as q7
|
||||
FROM generate_series(1, 10) as tbl(x);
|
||||
|
||||
# Non-CSE should not eliminate the 2nd quantile computation
|
||||
query II
|
||||
EXPLAIN FROM noncse;
|
||||
----
|
||||
physical_plan <REGEX>:.*quantile_disc\(x\).*quantile_disc\(x\).*
|
||||
38
external/duckdb/test/sql/window/test_window_dbplyr.test
vendored
Normal file
38
external/duckdb/test/sql/window/test_window_dbplyr.test
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# name: test/sql/window/test_window_dbplyr.test
|
||||
# description: Ensure dbplyr crash with ORDER BY under window stays fixed
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE dbplyr_052 (x INTEGER, g DOUBLE, w int)
|
||||
|
||||
statement ok
|
||||
INSERT INTO dbplyr_052 VALUES (1,1, 42),(2,1, 42),(3,1, 42),(2,2, 42),(3,2, 42),(4,2, 42)
|
||||
|
||||
# this works fine because we order by the already-projected column in the innermost query
|
||||
query IR rowsort
|
||||
SELECT x, g FROM (SELECT x, g, SUM(x) OVER (PARTITION BY g ORDER BY x ROWS UNBOUNDED PRECEDING) AS zzz67 FROM (SELECT x, g FROM dbplyr_052 ORDER BY x) dbplyr_053) dbplyr_054 WHERE (zzz67 > 3.0)
|
||||
----
|
||||
3 1.000000
|
||||
3 2.000000
|
||||
4 2.000000
|
||||
|
||||
# this breaks because we add a fake projection that is not pruned
|
||||
query IR rowsort
|
||||
SELECT x, g FROM (SELECT x, g, SUM(x) OVER (PARTITION BY g ORDER BY x ROWS UNBOUNDED PRECEDING) AS zzz67 FROM (SELECT x, g FROM dbplyr_052 ORDER BY w) dbplyr_053) dbplyr_054 WHERE (zzz67 > 3.0)
|
||||
----
|
||||
3 1.000000
|
||||
3 2.000000
|
||||
4 2.000000
|
||||
|
||||
# this also breaks because we add a fake projection that is not pruned even if we already have that projection,
|
||||
# just with a different table name
|
||||
query IR rowsort
|
||||
SELECT x, g FROM (SELECT x, g, SUM(x) OVER (PARTITION BY g ORDER BY x ROWS UNBOUNDED PRECEDING) AS zzz67 FROM (SELECT * FROM dbplyr_052 ORDER BY x) dbplyr_053) dbplyr_054 WHERE (zzz67 > 3.0)
|
||||
----
|
||||
3 1.000000
|
||||
3 2.000000
|
||||
4 2.000000
|
||||
|
||||
312
external/duckdb/test/sql/window/test_window_distinct.test
vendored
Normal file
312
external/duckdb/test/sql/window/test_window_distinct.test
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
# name: test/sql/window/test_window_distinct.test
|
||||
# description: Windowed distinct aggregates functionality
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT COUNT(DISTINCT 42) OVER ()
|
||||
----
|
||||
1
|
||||
|
||||
query IIII
|
||||
WITH t AS (
|
||||
SELECT col0 AS a, col1 AS b
|
||||
FROM (VALUES
|
||||
(1,2),
|
||||
(1,1),
|
||||
(1,2),
|
||||
(2,1),
|
||||
(2,1),
|
||||
(2,2),
|
||||
(2,3),
|
||||
(2,4)
|
||||
) v)
|
||||
SELECT *, COUNT(b) OVER(PARTITION BY a), COUNT(DISTINCT b) OVER(PARTITION BY a)
|
||||
FROM t
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
1 1 3 2
|
||||
1 2 3 2
|
||||
1 2 3 2
|
||||
2 1 5 4
|
||||
2 1 5 4
|
||||
2 2 5 4
|
||||
2 3 5 4
|
||||
2 4 5 4
|
||||
|
||||
statement ok
|
||||
CREATE TABLE figure1 AS
|
||||
SELECT *
|
||||
FROM VALUES
|
||||
(1, 'a'),
|
||||
(2, 'b'),
|
||||
(3, 'b'),
|
||||
(4, 'c'),
|
||||
(5, 'c'),
|
||||
(6, 'b'),
|
||||
(7, 'c'),
|
||||
(8, 'a')
|
||||
v(i, s);
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) OVER( ORDER BY i ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM figure1
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 2
|
||||
2 b 3
|
||||
3 b 3
|
||||
4 c 2
|
||||
5 c 2
|
||||
6 b 3
|
||||
7 c 3
|
||||
8 a 3
|
||||
|
||||
query III
|
||||
WITH uncascaded AS (
|
||||
SELECT i, i % 29 AS v
|
||||
FROM range(1000) tbl(i)
|
||||
)
|
||||
SELECT i
|
||||
, v
|
||||
, COUNT(DISTINCT v) OVER (ORDER BY i ROWS BETWEEN 25 PRECEDING AND 25 FOLLOWING) AS w
|
||||
FROM uncascaded
|
||||
ORDER BY i
|
||||
----
|
||||
3000 values hashing to cb9c296986f7b9eaeee380bbc049ab39
|
||||
|
||||
query III
|
||||
WITH cascaded AS (
|
||||
SELECT i, i % 29 AS v
|
||||
FROM range(10000) tbl(i)
|
||||
)
|
||||
SELECT i
|
||||
, v
|
||||
, COUNT(DISTINCT v) OVER (ORDER BY i ROWS BETWEEN 25 PRECEDING AND 25 FOLLOWING) AS w
|
||||
FROM cascaded
|
||||
ORDER BY i
|
||||
----
|
||||
30000 values hashing to 673869e81fecab82f0bcec032236115a
|
||||
|
||||
# Exclude falls back to naïve
|
||||
query IIII
|
||||
SELECT i
|
||||
, s
|
||||
, i // 2 AS o
|
||||
, COUNT(DISTINCT s) OVER(
|
||||
ORDER BY i // 2
|
||||
ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING
|
||||
EXCLUDE TIES
|
||||
) AS c
|
||||
FROM figure1
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 0 2
|
||||
2 b 1 3
|
||||
3 b 1 3
|
||||
4 c 2 2
|
||||
5 c 2 2
|
||||
6 b 3 3
|
||||
7 c 3 2
|
||||
8 a 4 3
|
||||
|
||||
# DISTINCT aggregate with NULL values in the dataset
|
||||
statement ok
|
||||
INSERT INTO figure1 VALUES
|
||||
(9, NULL),
|
||||
(NULL, 'b'),
|
||||
(NULL, NULL),
|
||||
;
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM figure1
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 a 2
|
||||
2 b 3
|
||||
3 b 3
|
||||
4 c 2
|
||||
5 c 2
|
||||
6 b 3
|
||||
7 c 3
|
||||
8 a 3
|
||||
9 NULL 3
|
||||
NULL b 2
|
||||
NULL NULL 1
|
||||
|
||||
# DISTINCT over nested types, e.g. LIST/STRUCT
|
||||
statement ok
|
||||
CREATE TABLE nested AS
|
||||
SELECT
|
||||
i,
|
||||
s,
|
||||
{"m": i % 2, "s": s} AS n,
|
||||
[(i % 2)::VARCHAR, s] AS l,
|
||||
i * i AS r
|
||||
FROM figure1
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, n
|
||||
, COUNT(DISTINCT n) OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 {'m': 1, 's': a} 3
|
||||
2 {'m': 0, 's': b} 4
|
||||
3 {'m': 1, 's': b} 5
|
||||
4 {'m': 0, 's': c} 4
|
||||
5 {'m': 1, 's': c} 4
|
||||
6 {'m': 0, 's': b} 4
|
||||
7 {'m': 1, 's': c} 4
|
||||
8 {'m': 0, 's': a} 5
|
||||
9 {'m': 1, 's': NULL} 5
|
||||
NULL {'m': NULL, 's': b} 4
|
||||
NULL {'m': NULL, 's': NULL} 3
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, l
|
||||
, COUNT(DISTINCT l) OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 [1, a] 3
|
||||
2 [0, b] 4
|
||||
3 [1, b] 5
|
||||
4 [0, c] 4
|
||||
5 [1, c] 4
|
||||
6 [0, b] 4
|
||||
7 [1, c] 4
|
||||
8 [0, a] 5
|
||||
9 [1, NULL] 5
|
||||
NULL [NULL, b] 4
|
||||
NULL [NULL, NULL] 3
|
||||
|
||||
# DISTINCT with RANGE instead of ROWS
|
||||
query III
|
||||
SELECT r
|
||||
, s
|
||||
, COUNT(DISTINCT s) OVER( ORDER BY r RANGE BETWEEN 10 PRECEDING AND 10 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 a 2
|
||||
4 b 2
|
||||
9 b 3
|
||||
16 c 2
|
||||
25 c 1
|
||||
36 b 1
|
||||
49 c 1
|
||||
64 a 1
|
||||
81 NULL 0
|
||||
NULL b 1
|
||||
NULL NULL 1
|
||||
|
||||
# DISTINCT with an aggregate with a destructor (e.g. LIST or STRING_AGG)
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, STRING_AGG(DISTINCT s, ', ') OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 a a, b
|
||||
2 b a, b, c
|
||||
3 b a, b, c
|
||||
4 c b, c
|
||||
5 c b, c
|
||||
6 b c, b, a
|
||||
7 c c, b, a
|
||||
8 a b, c, a
|
||||
9 NULL c, a, b
|
||||
NULL b a, b
|
||||
NULL NULL b
|
||||
|
||||
# DISTINCT MEDIAN, or distinct for aggregates that have a special window function?
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, MEDIAN(DISTINCT s) OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 a a
|
||||
2 b b
|
||||
3 b b
|
||||
4 c b
|
||||
5 c b
|
||||
6 b b
|
||||
7 c b
|
||||
8 a b
|
||||
9 NULL b
|
||||
NULL b a
|
||||
NULL NULL b
|
||||
|
||||
# DISTINCT FILTER
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s)
|
||||
FILTER (WHERE i % 3 = 0)
|
||||
OVER( ORDER BY i, s NULLS LAST ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
|
||||
AS c
|
||||
FROM nested
|
||||
ORDER BY i, s NULLS LAST
|
||||
----
|
||||
1 a 1
|
||||
2 b 1
|
||||
3 b 1
|
||||
4 c 1
|
||||
5 c 1
|
||||
6 b 1
|
||||
7 c 1
|
||||
8 a 1
|
||||
9 NULL 0
|
||||
NULL b 0
|
||||
NULL NULL 0
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) FILTER (WHERE i % 3 = 1) OVER( ORDER BY i ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 1
|
||||
2 b 2
|
||||
3 b 2
|
||||
4 c 1
|
||||
5 c 1
|
||||
6 b 1
|
||||
7 c 1
|
||||
8 a 1
|
||||
9 NULL 1
|
||||
NULL b 0
|
||||
NULL NULL 0
|
||||
|
||||
query III
|
||||
SELECT i
|
||||
, s
|
||||
, COUNT(DISTINCT s) FILTER (WHERE i % 3 = 2) OVER( ORDER BY i ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS c
|
||||
FROM nested
|
||||
ORDER BY i
|
||||
----
|
||||
1 a 1
|
||||
2 b 1
|
||||
3 b 2
|
||||
4 c 2
|
||||
5 c 1
|
||||
6 b 2
|
||||
7 c 2
|
||||
8 a 1
|
||||
9 NULL 1
|
||||
NULL b 1
|
||||
NULL NULL 0
|
||||
43
external/duckdb/test/sql/window/test_window_distinct.test_slow
vendored
Normal file
43
external/duckdb/test/sql/window/test_window_distinct.test_slow
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# name: test/sql/window/test_window_distinct.test_slow
|
||||
# description: Windowed distinct aggregates at scale
|
||||
# group: [window]
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
CALL dbgen(sf=1);
|
||||
|
||||
statement ok
|
||||
PRAGMA temp_directory='__TEST_DIR__/window_distinct'
|
||||
|
||||
# DISTINCT aggregate over a larger data set (e.g. lineitem or so)
|
||||
query I
|
||||
SELECT
|
||||
l_orderkey,
|
||||
l_linenumber,
|
||||
l_returnflag,
|
||||
COUNT(DISTINCT l_returnflag) OVER(PARTITION BY l_orderkey ORDER BY l_linenumber)
|
||||
FROM lineitem
|
||||
ORDER BY ALL
|
||||
----
|
||||
24004860 values hashing to d39903ddf93011916ff3354d8bded7ff
|
||||
|
||||
# Trigger external sorting of a partition
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
# The actual memory consumption of this query is 1.5GB
|
||||
# So this is a serious level of stress.
|
||||
statement ok
|
||||
PRAGMA memory_limit='500MB'
|
||||
|
||||
query I
|
||||
WITH t AS (
|
||||
SELECT range AS i, CHR((65 + i % 26)::INTEGER) AS c
|
||||
FROM range(1e6::BIGINT)
|
||||
)
|
||||
SELECT i, c, COUNT(DISTINCT c) OVER (ORDER BY i DESC) AS n
|
||||
FROM t
|
||||
ORDER BY ALL
|
||||
----
|
||||
3000000 values hashing to f56f9b4e62101f52951e1f01a9b5c862
|
||||
885
external/duckdb/test/sql/window/test_window_exclude.test_slow
vendored
Normal file
885
external/duckdb/test/sql/window/test_window_exclude.test_slow
vendored
Normal file
@@ -0,0 +1,885 @@
|
||||
# name: test/sql/window/test_window_exclude.test_slow
|
||||
# description: Windows with EXCLUDE clause
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tenk1d (
|
||||
unique1 int4,
|
||||
four int4,
|
||||
col int4
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO tenk1d (unique1, four, col) VALUES
|
||||
(0, 0, NULL),
|
||||
(1, 1, 1),
|
||||
(2, 2, NULL),
|
||||
(3, 3, 3),
|
||||
(4, 0, NULL),
|
||||
(5, 1, 1),
|
||||
(6, 2, NULL),
|
||||
(7, 3, 3),
|
||||
(8, 0, NULL),
|
||||
(9, 1, 1);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE empsalary (
|
||||
depname varchar,
|
||||
empno bigint,
|
||||
salary int,
|
||||
enroll_date date
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO empsalary VALUES
|
||||
('develop', 10, 5200, '2007-08-01'),
|
||||
('sales', 1, 5000, '2006-10-01'),
|
||||
('personnel', 5, 3500, '2007-12-10'),
|
||||
('sales', 4, 4800, '2007-08-08'),
|
||||
('personnel', 2, 3900, '2006-12-23'),
|
||||
('develop', 7, 4200, '2008-01-01'),
|
||||
('develop', 9, 4500, '2008-01-01'),
|
||||
('sales', 3, 4800, '2007-08-01'),
|
||||
('develop', 8, 6000, '2006-10-01'),
|
||||
('develop', 11, 5200, '2007-08-15');
|
||||
|
||||
# RANGE + CURRENT ROW
|
||||
query III
|
||||
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row),
|
||||
unique1, four
|
||||
FROM tenk1d WINDOW w AS (order by four) ORDER BY four, unique1;
|
||||
----
|
||||
12 0 0
|
||||
8 4 0
|
||||
4 8 0
|
||||
26 1 1
|
||||
22 5 1
|
||||
18 9 1
|
||||
33 2 2
|
||||
29 6 2
|
||||
42 3 3
|
||||
38 7 3
|
||||
|
||||
# RANGE + GROUP
|
||||
query III
|
||||
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group),
|
||||
unique1, four
|
||||
FROM tenk1d WINDOW w AS (order by four) ORDER BY four, unique1;
|
||||
----
|
||||
NULL 0 0
|
||||
NULL 4 0
|
||||
NULL 8 0
|
||||
12 1 1
|
||||
12 5 1
|
||||
12 9 1
|
||||
27 2 2
|
||||
27 6 2
|
||||
35 3 3
|
||||
35 7 3
|
||||
|
||||
# RANGE + TIES
|
||||
query III
|
||||
SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties),
|
||||
unique1, four
|
||||
FROM tenk1d WINDOW w AS (order by four) ORDER BY four, unique1;
|
||||
----
|
||||
0 0 0
|
||||
4 4 0
|
||||
8 8 0
|
||||
13 1 1
|
||||
17 5 1
|
||||
21 9 1
|
||||
29 2 2
|
||||
33 6 2
|
||||
38 3 3
|
||||
42 7 3
|
||||
|
||||
# with PARTITION BY
|
||||
query III
|
||||
SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following
|
||||
exclude current row),unique1, four
|
||||
FROM tenk1d ORDER BY four, unique1;
|
||||
----
|
||||
4 0 0
|
||||
8 4 0
|
||||
4 8 0
|
||||
5 1 1
|
||||
10 5 1
|
||||
5 9 1
|
||||
6 2 2
|
||||
2 6 2
|
||||
7 3 3
|
||||
3 7 3
|
||||
|
||||
# with FILTER
|
||||
query III
|
||||
SELECT sum(unique1) filter (where four > 1)over (order by unique1 rows between unbounded preceding and current row
|
||||
exclude current row),unique1, four
|
||||
FROM tenk1d ORDER BY unique1, four;
|
||||
----
|
||||
NULL 0 0
|
||||
NULL 1 1
|
||||
NULL 2 2
|
||||
2 3 3
|
||||
5 4 0
|
||||
5 5 1
|
||||
5 6 2
|
||||
11 7 3
|
||||
18 8 0
|
||||
18 9 1
|
||||
|
||||
# with FILTER and PARTITION BY
|
||||
query III
|
||||
SELECT sum(unique1) filter (where four > 0) over (partition by four order by unique1 rows between unbounded preceding
|
||||
and current row exclude current row),unique1, four
|
||||
FROM tenk1d ORDER BY unique1, four;
|
||||
----
|
||||
NULL 0 0
|
||||
NULL 1 1
|
||||
NULL 2 2
|
||||
NULL 3 3
|
||||
NULL 4 0
|
||||
1 5 1
|
||||
2 6 2
|
||||
3 7 3
|
||||
NULL 8 0
|
||||
6 9 1
|
||||
|
||||
# first_value
|
||||
query II
|
||||
SELECT first_value(four) over (order by four rows between unbounded preceding
|
||||
and current row exclude group), four
|
||||
FROM tenk1d ORDER BY four;
|
||||
----
|
||||
NULL 0
|
||||
NULL 0
|
||||
NULL 0
|
||||
0 1
|
||||
0 1
|
||||
0 1
|
||||
0 2
|
||||
0 2
|
||||
0 3
|
||||
0 3
|
||||
|
||||
|
||||
# last_value
|
||||
query II
|
||||
SELECT last_value(four) over (order by four rows between current row
|
||||
and unbounded following exclude current row), four
|
||||
FROM tenk1d ORDER BY four;
|
||||
----
|
||||
3 0
|
||||
3 0
|
||||
3 0
|
||||
3 1
|
||||
3 1
|
||||
3 1
|
||||
3 2
|
||||
3 2
|
||||
3 3
|
||||
NULL 3
|
||||
|
||||
|
||||
# nth_value
|
||||
query II
|
||||
SELECT nth_value(four, 5) over (order by four rows between unbounded preceding
|
||||
and unbounded following exclude ties), four
|
||||
FROM tenk1d ORDER BY four;
|
||||
----
|
||||
2 0
|
||||
2 0
|
||||
2 0
|
||||
2 1
|
||||
2 1
|
||||
2 1
|
||||
1 2
|
||||
1 2
|
||||
1 3
|
||||
1 3
|
||||
|
||||
|
||||
|
||||
# IGNORE NULLS
|
||||
query III
|
||||
SELECT nth_value(col, 3 ignore nulls) over (order by four rows between unbounded preceding
|
||||
and unbounded following exclude current row),four, col
|
||||
FROM tenk1d ORDER BY four, col;
|
||||
----
|
||||
1 0 NULL
|
||||
1 0 NULL
|
||||
1 0 NULL
|
||||
3 1 1
|
||||
3 1 1
|
||||
3 1 1
|
||||
1 2 NULL
|
||||
1 2 NULL
|
||||
1 3 3
|
||||
1 3 3
|
||||
|
||||
|
||||
# IGNORE NULLS with input > STANDARD_VECTOR_SIZE
|
||||
query I
|
||||
SELECT DISTINCT first_value(col IGNORE NULLS) OVER (ORDER BY i ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW)
|
||||
FROM ( SELECT *
|
||||
FROM generate_series(1,3000) AS _(i), (SELECT NULL::integer)
|
||||
UNION ALL
|
||||
SELECT 3001, 1
|
||||
) AS _(i, col)
|
||||
ORDER BY ALL NULLS FIRST;
|
||||
----
|
||||
NULL
|
||||
1
|
||||
|
||||
|
||||
# without ORDER BY: EXCLUDE CURRENT ROW / constant aggregate otherwise
|
||||
query II
|
||||
SELECT sum(unique1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW), unique1
|
||||
FROM tenk1d ORDER BY unique1;
|
||||
----
|
||||
45 0
|
||||
44 1
|
||||
43 2
|
||||
42 3
|
||||
41 4
|
||||
40 5
|
||||
39 6
|
||||
38 7
|
||||
37 8
|
||||
36 9
|
||||
|
||||
|
||||
# without ORDER BY: EXCLUDE GROUP / constant aggregate otherwise
|
||||
query II
|
||||
SELECT sum(unique1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP), unique1
|
||||
FROM tenk1d ORDER BY unique1;
|
||||
----
|
||||
NULL 0
|
||||
NULL 1
|
||||
NULL 2
|
||||
NULL 3
|
||||
NULL 4
|
||||
NULL 5
|
||||
NULL 6
|
||||
NULL 7
|
||||
NULL 8
|
||||
NULL 9
|
||||
|
||||
|
||||
# without ORDER BY: EXCLUDE TIES / constant aggregate otherwise
|
||||
query II
|
||||
SELECT sum(unique1) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES), unique1
|
||||
FROM tenk1d ORDER BY unique1;
|
||||
----
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
|
||||
# input larger than standard vector size (with EXCLUDE GROUP and vector-crossing peer boundary)
|
||||
query II
|
||||
SELECT DISTINCT j,sum(j) OVER (ORDER BY j ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM generate_series(1,300), generate_series(1,10) AS __(j) ORDER BY j;
|
||||
----
|
||||
1 16200
|
||||
2 15900
|
||||
3 15600
|
||||
4 15300
|
||||
5 15000
|
||||
6 14700
|
||||
7 14400
|
||||
8 14100
|
||||
9 13800
|
||||
10 13500
|
||||
|
||||
|
||||
# with WHERE clause
|
||||
query II
|
||||
SELECT i, last_value(i) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM generate_series(1,10) AS _(i)
|
||||
WHERE i <> 10
|
||||
ORDER BY i;
|
||||
----
|
||||
1 9
|
||||
2 9
|
||||
3 9
|
||||
4 9
|
||||
5 9
|
||||
6 9
|
||||
7 9
|
||||
8 9
|
||||
9 8
|
||||
|
||||
|
||||
# regression test
|
||||
query II
|
||||
SELECT DISTINCT j,sum(j) OVER (ORDER BY j ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM generate_series(1,300), generate_series(1,10) AS __(j) ORDER BY j;
|
||||
----
|
||||
1 16201
|
||||
2 15902
|
||||
3 15603
|
||||
4 15304
|
||||
5 15005
|
||||
6 14706
|
||||
7 14407
|
||||
8 14108
|
||||
9 13809
|
||||
10 13510
|
||||
|
||||
# regression test
|
||||
query II
|
||||
SELECT DISTINCT j,sum(j) FILTER (where i <> 3) OVER (ORDER BY j ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) AS sum FROM generate_series(1,300) _(i), generate_series(1,10) AS __(j) ORDER BY j, sum;
|
||||
----
|
||||
1 16146
|
||||
1 16147
|
||||
2 15847
|
||||
2 15849
|
||||
3 15548
|
||||
3 15551
|
||||
4 15249
|
||||
4 15253
|
||||
5 14950
|
||||
5 14955
|
||||
6 14651
|
||||
6 14657
|
||||
7 14352
|
||||
7 14359
|
||||
8 14053
|
||||
8 14061
|
||||
9 13754
|
||||
9 13763
|
||||
10 13455
|
||||
10 13465
|
||||
|
||||
# regression test
|
||||
query II
|
||||
SELECT j, sum(j) OVER (ORDER BY j ROWS BETWEEN UNBOUNDED PRECEDING AND 30 FOLLOWING EXCLUDE CURRENT ROW) FROM generate_series(1,40) AS _(j) ORDER BY j;
|
||||
----
|
||||
1 495
|
||||
2 526
|
||||
3 558
|
||||
4 591
|
||||
5 625
|
||||
6 660
|
||||
7 696
|
||||
8 733
|
||||
9 771
|
||||
10 810
|
||||
11 809
|
||||
12 808
|
||||
13 807
|
||||
14 806
|
||||
15 805
|
||||
16 804
|
||||
17 803
|
||||
18 802
|
||||
19 801
|
||||
20 800
|
||||
21 799
|
||||
22 798
|
||||
23 797
|
||||
24 796
|
||||
25 795
|
||||
26 794
|
||||
27 793
|
||||
28 792
|
||||
29 791
|
||||
30 790
|
||||
31 789
|
||||
32 788
|
||||
33 787
|
||||
34 786
|
||||
35 785
|
||||
36 784
|
||||
37 783
|
||||
38 782
|
||||
39 781
|
||||
40 780
|
||||
|
||||
# Query otherwise handled by STREAMING WINDOW
|
||||
query TT
|
||||
EXPLAIN
|
||||
SELECT unique1, COUNT(*) OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) FROM tenk1d;
|
||||
----
|
||||
physical_plan <!REGEX>:.*STREAMING_WINDOW.*
|
||||
|
||||
|
||||
|
||||
# PARTITION BY without ORDER BY
|
||||
query III
|
||||
SELECT unique1, four, sum(unique1) OVER (PARTITION BY four ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW) FROM tenk1d ORDER BY four, unique1;
|
||||
----
|
||||
0 0 12
|
||||
4 0 8
|
||||
8 0 4
|
||||
1 1 14
|
||||
5 1 10
|
||||
9 1 6
|
||||
2 2 6
|
||||
6 2 2
|
||||
3 3 7
|
||||
7 3 3
|
||||
|
||||
# PARTITION BY without ORDER BY
|
||||
query III
|
||||
SELECT unique1, four, sum(unique1) OVER (PARTITION BY four ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE GROUP) FROM tenk1d ORDER BY four, unique1;
|
||||
----
|
||||
0 0 NULL
|
||||
4 0 NULL
|
||||
8 0 NULL
|
||||
1 1 NULL
|
||||
5 1 NULL
|
||||
9 1 NULL
|
||||
2 2 NULL
|
||||
6 2 NULL
|
||||
3 3 NULL
|
||||
7 3 NULL
|
||||
|
||||
|
||||
# PARTITION BY without ORDER BY
|
||||
query III
|
||||
SELECT unique1, four, sum(unique1) OVER (PARTITION BY four ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE TIES) FROM tenk1d ORDER BY four, unique1;
|
||||
----
|
||||
0 0 0
|
||||
4 0 4
|
||||
8 0 8
|
||||
1 1 1
|
||||
5 1 5
|
||||
9 1 9
|
||||
2 2 2
|
||||
6 2 6
|
||||
3 3 3
|
||||
7 3 7
|
||||
|
||||
|
||||
#
|
||||
# Custom aggregates (not implemented yet)
|
||||
#
|
||||
|
||||
## COUNT(*) and CURRENT ROW
|
||||
query II
|
||||
SELECT i, COUNT(*) OVER (ORDER BY i ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING EXCLUDE CURRENT ROW)
|
||||
FROM generate_series(1,10) AS _(i)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 3
|
||||
2 4
|
||||
3 5
|
||||
4 6
|
||||
5 6
|
||||
6 6
|
||||
7 6
|
||||
8 5
|
||||
9 4
|
||||
10 3
|
||||
|
||||
## COUNT(*) and GROUP
|
||||
query II
|
||||
SELECT i, COUNT(*) OVER (ORDER BY i ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING EXCLUDE GROUP)
|
||||
FROM (
|
||||
SELECT * FROM generate_series(1,5)
|
||||
UNION ALL
|
||||
SELECT * FROM generate_series(1,5)
|
||||
) AS _(i)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 2
|
||||
1 3
|
||||
2 4
|
||||
2 5
|
||||
3 5
|
||||
3 5
|
||||
4 5
|
||||
4 4
|
||||
5 3
|
||||
5 2
|
||||
|
||||
|
||||
## COUNT(*) and TIES
|
||||
query II
|
||||
SELECT i, COUNT(*) OVER (ORDER BY i ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING EXCLUDE TIES)
|
||||
FROM (
|
||||
SELECT * FROM generate_series(1,5)
|
||||
UNION ALL
|
||||
SELECT * FROM generate_series(1,5))
|
||||
AS _(i)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 3
|
||||
1 4
|
||||
2 5
|
||||
2 6
|
||||
3 6
|
||||
3 6
|
||||
4 6
|
||||
4 5
|
||||
5 4
|
||||
5 3
|
||||
|
||||
## ARRAY_AGG and CURRENT ROW
|
||||
query II
|
||||
SELECT i, array_agg(i) OVER w AS aai
|
||||
FROM (
|
||||
SELECT * FROM generate_series(1,5)
|
||||
UNION ALL
|
||||
SELECT * FROM generate_series(1,5)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS UNBOUNDED PRECEDING EXCLUDE CURRENT ROW)
|
||||
ORDER BY i, aai NULLS FIRST;
|
||||
----
|
||||
1 NULL
|
||||
1 [1]
|
||||
2 [1, 1]
|
||||
2 [1, 1, 2]
|
||||
3 [1, 1, 2, 2]
|
||||
3 [1, 1, 2, 2, 3]
|
||||
4 [1, 1, 2, 2, 3, 3]
|
||||
4 [1, 1, 2, 2, 3, 3, 4]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4, 5]
|
||||
|
||||
## ARRAY_AGG and GROUP
|
||||
query II
|
||||
SELECT i, array_agg(i) OVER w
|
||||
FROM (
|
||||
SELECT * FROM generate_series(1,5)
|
||||
UNION ALL
|
||||
SELECT * FROM generate_series(1,5)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS UNBOUNDED PRECEDING EXCLUDE GROUP)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 NULL
|
||||
1 NULL
|
||||
2 [1, 1]
|
||||
2 [1, 1]
|
||||
3 [1, 1, 2, 2]
|
||||
3 [1, 1, 2, 2]
|
||||
4 [1, 1, 2, 2, 3, 3]
|
||||
4 [1, 1, 2, 2, 3, 3]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4]
|
||||
|
||||
## ARRAY_AGG and TIES
|
||||
query II
|
||||
SELECT i, array_agg(i) OVER w
|
||||
FROM (
|
||||
SELECT * FROM generate_series(1,5)
|
||||
UNION ALL
|
||||
SELECT * FROM generate_series(1,5)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS UNBOUNDED PRECEDING EXCLUDE TIES)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 [1]
|
||||
1 [1]
|
||||
2 [1, 1, 2]
|
||||
2 [1, 1, 2]
|
||||
3 [1, 1, 2, 2, 3]
|
||||
3 [1, 1, 2, 2, 3]
|
||||
4 [1, 1, 2, 2, 3, 3, 4]
|
||||
4 [1, 1, 2, 2, 3, 3, 4]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4, 5]
|
||||
5 [1, 1, 2, 2, 3, 3, 4, 4, 5]
|
||||
|
||||
# MODE and CURRENT ROW
|
||||
query II
|
||||
SELECT i, mode(i) OVER w
|
||||
FROM (
|
||||
SELECT i FROM generate_series(1,3) t(i), range(4)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW)
|
||||
ORDER BY ALL;
|
||||
----
|
||||
1 1
|
||||
1 1
|
||||
1 1
|
||||
1 2
|
||||
2 2
|
||||
2 2
|
||||
2 2
|
||||
2 3
|
||||
3 3
|
||||
3 3
|
||||
3 3
|
||||
3 3
|
||||
|
||||
# MODE and GROUP
|
||||
query II
|
||||
SELECT i, mode(i) OVER w
|
||||
FROM (
|
||||
SELECT i FROM generate_series(1,3) t(i), range(4)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE GROUP)
|
||||
ORDER BY ALL;
|
||||
----
|
||||
1 2
|
||||
1 2
|
||||
1 NULL
|
||||
1 NULL
|
||||
2 1
|
||||
2 3
|
||||
2 3
|
||||
2 NULL
|
||||
3 2
|
||||
3 NULL
|
||||
3 NULL
|
||||
3 NULL
|
||||
|
||||
# MODE and TIES
|
||||
query II
|
||||
SELECT i, mode(i) OVER w
|
||||
FROM (
|
||||
FROM repeat(1, 10)
|
||||
UNION ALL
|
||||
FROM repeat(2, 4)
|
||||
UNION ALL
|
||||
FROM repeat(3, 5)
|
||||
) AS _(i)
|
||||
WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 100 FOLLOWING EXCLUDE TIES)
|
||||
ORDER BY ALL;
|
||||
----
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
1 3
|
||||
2 3
|
||||
2 3
|
||||
2 3
|
||||
2 3
|
||||
3 3
|
||||
3 3
|
||||
3 3
|
||||
3 3
|
||||
3 3
|
||||
|
||||
# MEDIAN and CURRENT ROW
|
||||
query II
|
||||
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE CURRENT ROW)
|
||||
FROM generate_series(1,10) AS _(i) ORDER BY i;
|
||||
----
|
||||
1 2.5
|
||||
2 3.0
|
||||
3 4.0
|
||||
4 5.0
|
||||
5 6.0
|
||||
6 7.0
|
||||
7 8.0
|
||||
8 9.0
|
||||
9 9.0
|
||||
10 9.0
|
||||
|
||||
# MEDIAN and GROUP
|
||||
query II
|
||||
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE GROUP)
|
||||
FROM generate_series(1,5) AS _(i),
|
||||
generate_series(1,2)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 2.0
|
||||
1 2.0
|
||||
2 2.0
|
||||
2 3.0
|
||||
3 3.0
|
||||
3 4.0
|
||||
4 4.0
|
||||
4 5.0
|
||||
5 4.0
|
||||
5 NULL
|
||||
|
||||
# MEDIAN and TIES
|
||||
query II
|
||||
SELECT i, median(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 2 FOLLOWING EXCLUDE TIES)
|
||||
FROM generate_series(1,5) AS _(i),
|
||||
generate_series(1,2)
|
||||
ORDER BY i;
|
||||
----
|
||||
1 1.5
|
||||
1 2.0
|
||||
2 2.0
|
||||
2 3.0
|
||||
3 3.0
|
||||
3 4.0
|
||||
4 4.0
|
||||
4 5.0
|
||||
5 4.5
|
||||
5 5.0
|
||||
|
||||
# Test Merge Sort Trees with exclusions
|
||||
query III
|
||||
WITH t1(x, y) AS (VALUES
|
||||
( 1, 3 ),
|
||||
( 2, 2 ),
|
||||
( 3, 1 )
|
||||
)
|
||||
SELECT x, y, QUANTILE_DISC(y, 0) OVER (
|
||||
ORDER BY x
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
|
||||
EXCLUDE CURRENT ROW)
|
||||
FROM t1;
|
||||
----
|
||||
1 3 NULL
|
||||
2 2 3
|
||||
3 1 2
|
||||
|
||||
query III
|
||||
WITH t1(x, y) AS (VALUES
|
||||
( 1, 3 ),
|
||||
( 2, 2 ),
|
||||
( 3, 1 )
|
||||
)
|
||||
SELECT x, y, QUANTILE_DISC(y, 0) OVER (
|
||||
ORDER BY x
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
|
||||
EXCLUDE CURRENT ROW)
|
||||
FROM t1;
|
||||
----
|
||||
1 3 1
|
||||
2 2 1
|
||||
3 1 2
|
||||
|
||||
|
||||
# PG test
|
||||
query III
|
||||
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following
|
||||
exclude current row), salary, enroll_date from empsalary ORDER BY enroll_date, salary;
|
||||
----
|
||||
29900 5000 2006-10-01
|
||||
28900 6000 2006-10-01
|
||||
34500 3900 2006-12-23
|
||||
42300 4800 2007-08-01
|
||||
41900 5200 2007-08-01
|
||||
42300 4800 2007-08-08
|
||||
41900 5200 2007-08-15
|
||||
32600 3500 2007-12-10
|
||||
28000 4200 2008-01-01
|
||||
27700 4500 2008-01-01
|
||||
|
||||
# PG test
|
||||
query III
|
||||
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following
|
||||
exclude group), salary, enroll_date from empsalary ORDER BY enroll_date, salary;
|
||||
----
|
||||
23900 5000 2006-10-01
|
||||
23900 6000 2006-10-01
|
||||
34500 3900 2006-12-23
|
||||
37100 4800 2007-08-01
|
||||
37100 5200 2007-08-01
|
||||
42300 4800 2007-08-08
|
||||
41900 5200 2007-08-15
|
||||
32600 3500 2007-12-10
|
||||
23500 4200 2008-01-01
|
||||
23500 4500 2008-01-01
|
||||
|
||||
# PG test
|
||||
query III
|
||||
select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following
|
||||
exclude ties), salary, enroll_date from empsalary ORDER BY enroll_date, salary;
|
||||
----
|
||||
28900 5000 2006-10-01
|
||||
29900 6000 2006-10-01
|
||||
38400 3900 2006-12-23
|
||||
41900 4800 2007-08-01
|
||||
42300 5200 2007-08-01
|
||||
47100 4800 2007-08-08
|
||||
47100 5200 2007-08-15
|
||||
36100 3500 2007-12-10
|
||||
27700 4200 2008-01-01
|
||||
28000 4500 2008-01-01
|
||||
|
||||
# PG test
|
||||
query IIII
|
||||
select first_value(salary) over(order by salary range between 1000 preceding and 1000 following) AS first_value,
|
||||
lead(salary) over(order by salary range between 1000 preceding and 1000 following) AS lead,
|
||||
nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following),
|
||||
salary from empsalary ORDER BY first_value, lead;
|
||||
----
|
||||
3500 3900 3500 3500
|
||||
3500 4200 3500 3900
|
||||
3500 4500 3500 4200
|
||||
3500 4800 3500 4500
|
||||
3900 4800 3900 4800
|
||||
3900 5000 3900 4800
|
||||
4200 5200 4200 5000
|
||||
4200 5200 4200 5200
|
||||
4200 6000 4200 5200
|
||||
5000 NULL 5000 6000
|
||||
|
||||
# PG test
|
||||
query III
|
||||
select last_value(salary) over(order by salary range between 1000 preceding and 1000 following) AS last_value,
|
||||
lag(salary) over(order by salary range between 1000 preceding and 1000 following) AS lag,
|
||||
salary from empsalary ORDER BY last_value, lag;
|
||||
----
|
||||
4500 NULL 3500
|
||||
4800 3500 3900
|
||||
5200 3900 4200
|
||||
5200 4200 4500
|
||||
5200 4500 4800
|
||||
5200 4800 4800
|
||||
6000 4800 5000
|
||||
6000 5000 5200
|
||||
6000 5200 5200
|
||||
6000 5200 6000
|
||||
|
||||
# PG test
|
||||
query IIII
|
||||
select first_value(salary) over(order by salary range between 1000 following and 3000 following
|
||||
exclude current row) AS first_value,
|
||||
lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties) AS lead,
|
||||
nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following
|
||||
exclude ties),
|
||||
salary from empsalary ORDER BY first_value, lead;
|
||||
----
|
||||
4500 3900 4500 3500
|
||||
5000 4200 5000 3900
|
||||
5200 4500 5200 4200
|
||||
6000 4800 6000 4500
|
||||
6000 4800 6000 4800
|
||||
6000 5000 6000 4800
|
||||
6000 5200 6000 5000
|
||||
NULL 5200 NULL 5200
|
||||
NULL 6000 NULL 5200
|
||||
NULL NULL NULL 6000
|
||||
|
||||
# PG test
|
||||
query III
|
||||
select last_value(salary) over(order by salary range between 1000 following and 3000 following
|
||||
exclude group) AS last_value,
|
||||
lag(salary) over(order by salary range between 1000 following and 3000 following exclude group) AS lag,
|
||||
salary from empsalary ORDER BY last_value, lag;
|
||||
----
|
||||
6000 3500 3900
|
||||
6000 3900 4200
|
||||
6000 4200 4500
|
||||
6000 4500 4800
|
||||
6000 4800 4800
|
||||
6000 4800 5000
|
||||
6000 NULL 3500
|
||||
NULL 5000 5200
|
||||
NULL 5200 5200
|
||||
NULL 5200 6000
|
||||
|
||||
|
||||
statement error
|
||||
SELECT sum(i) OVER (EXCLUDE CURRENT ROW) FROM generate_series(1,10) AS _(i);
|
||||
----
|
||||
Parser Error: syntax error at or near "CURRENT"
|
||||
|
||||
statement error
|
||||
SELECT sum(i) OVER (ROWS UNBOUNDED PRECEDING EXCLUDE GROUPS) FROM generate_series(1,10) AS _(i);
|
||||
----
|
||||
Parser Error: syntax error at or near "GROUPS"
|
||||
157
external/duckdb/test/sql/window/test_window_filter.test
vendored
Normal file
157
external/duckdb/test/sql/window/test_window_filter.test
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
# name: test/sql/window/test_window_filter.test
|
||||
# description: FILTER clause for WINDOW functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE testing AS
|
||||
SELECT
|
||||
x
|
||||
,round(x * 0.333,0) % 3 AS y
|
||||
,round(x * 0.333,0) % 3 AS z
|
||||
FROM generate_series(0,10) tbl(x);
|
||||
|
||||
# The x_filtered_window and z_filtered_window columns should return a different output than plain_window
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,avg(x) OVER (PARTITION BY y) AS plain_window
|
||||
,avg(x) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,avg(x) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
1 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
8 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
9 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
10 0.000000 0.000000 5.600000 1.000000 5.600000
|
||||
2 1.000000 1.000000 3.000000 NULL NULL
|
||||
3 1.000000 1.000000 3.000000 NULL NULL
|
||||
4 1.000000 1.000000 3.000000 NULL NULL
|
||||
5 2.000000 2.000000 6.000000 NULL NULL
|
||||
6 2.000000 2.000000 6.000000 NULL NULL
|
||||
7 2.000000 2.000000 6.000000 NULL NULL
|
||||
|
||||
# COUNT(*) coverage
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,count(*) OVER (PARTITION BY y) AS plain_window
|
||||
,count(*) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,count(*) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 5 1 5
|
||||
1 0.000000 0.000000 5 1 5
|
||||
8 0.000000 0.000000 5 1 5
|
||||
9 0.000000 0.000000 5 1 5
|
||||
10 0.000000 0.000000 5 1 5
|
||||
2 1.000000 1.000000 3 0 0
|
||||
3 1.000000 1.000000 3 0 0
|
||||
4 1.000000 1.000000 3 0 0
|
||||
5 2.000000 2.000000 3 0 0
|
||||
6 2.000000 2.000000 3 0 0
|
||||
7 2.000000 2.000000 3 0 0
|
||||
|
||||
# Holistic coverage
|
||||
query IIIIII
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
,median(x) OVER (PARTITION BY y) AS plain_window
|
||||
,median(x) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
,median(x) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
0 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
1 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
8 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
9 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
10 0.000000 0.000000 8.000000 1.000000 8.000000
|
||||
2 1.000000 1.000000 3.000000 NULL NULL
|
||||
3 1.000000 1.000000 3.000000 NULL NULL
|
||||
4 1.000000 1.000000 3.000000 NULL NULL
|
||||
5 2.000000 2.000000 6.000000 NULL NULL
|
||||
6 2.000000 2.000000 6.000000 NULL NULL
|
||||
7 2.000000 2.000000 6.000000 NULL NULL
|
||||
|
||||
# Filters do not affect framing.
|
||||
query II
|
||||
SELECT x, count(x) FILTER (WHERE x % 2 = 0) OVER (ORDER BY x ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
|
||||
FROM generate_series(0,10) tbl(x);
|
||||
----
|
||||
0 2
|
||||
1 2
|
||||
2 3
|
||||
3 2
|
||||
4 3
|
||||
5 2
|
||||
6 3
|
||||
7 2
|
||||
8 3
|
||||
9 2
|
||||
10 2
|
||||
|
||||
#
|
||||
# Errors
|
||||
#
|
||||
|
||||
# Non-aggregates do not support filtering.
|
||||
|
||||
foreach nullary rank dense_rank row_number percent_rank cume_dist
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
, ${nullary}() OVER (PARTITION BY y) AS plain_window
|
||||
, ${nullary}() FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
, ${nullary}() FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
foreach unary ntile first_value last_value lead lag
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
, ${unary}(x) OVER (PARTITION BY y) AS plain_window
|
||||
, ${unary}(x) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
, ${unary}(x) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
|
||||
endloop
|
||||
|
||||
foreach binary nth_value
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
x
|
||||
,y
|
||||
,z
|
||||
, ${binary}(x, 1) OVER (PARTITION BY y) AS plain_window
|
||||
, ${binary}(x, 1) FILTER (WHERE x = 1) OVER (PARTITION BY y) AS x_filtered_window
|
||||
, ${binary}(x, 1) FILTER (WHERE z = 0) OVER (PARTITION BY y) AS z_filtered_window
|
||||
FROM testing
|
||||
ORDER BY y, x;
|
||||
----
|
||||
|
||||
endloop
|
||||
724
external/duckdb/test/sql/window/test_window_fusion.test
vendored
Normal file
724
external/duckdb/test/sql/window/test_window_fusion.test
vendored
Normal file
@@ -0,0 +1,724 @@
|
||||
# name: test/sql/window/test_window_fusion.test
|
||||
# description: Prefix sort fusion
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# Subset of lineitem with only two partitions
|
||||
statement ok
|
||||
create table lineitem (
|
||||
l_extendedprice decimal(15,2),
|
||||
l_partkey integer,
|
||||
l_orderkey integer
|
||||
);
|
||||
|
||||
statement ok
|
||||
insert into lineitem (values
|
||||
(29733.00, 1, 2883),
|
||||
(1802.00, 1, 5121),
|
||||
(4505.00, 1, 6179),
|
||||
(29733.00, 1, 6273),
|
||||
(30634.00, 1, 8645),
|
||||
(41446.00, 1, 12005),
|
||||
(36040.00, 1, 16135),
|
||||
(29733.00, 1, 16198),
|
||||
(26129.00, 1, 20199),
|
||||
(24327.00, 1, 22117),
|
||||
(19822.00, 1, 24866),
|
||||
(24327.00, 1, 26756),
|
||||
(9010.00, 1, 27558),
|
||||
(45050.00, 1, 29859),
|
||||
(2703.00, 1, 34692),
|
||||
(11713.00, 1, 36611),
|
||||
(18020.00, 1, 38051),
|
||||
(21624.00, 1, 42465),
|
||||
(36040.00, 1, 42758),
|
||||
(39644.00, 1, 47620),
|
||||
(28832.00, 1, 50498),
|
||||
(12614.00, 1, 51970),
|
||||
(2703.00, 1, 53189),
|
||||
(22525.00, 1, 53825),
|
||||
(21624.00, 1, 54592),
|
||||
(36941.00, 1, 59202),
|
||||
(18942.00, 2, 548),
|
||||
(17138.00, 2, 807),
|
||||
(24354.00, 2, 2117),
|
||||
(9020.00, 2, 2528),
|
||||
(28864.00, 2, 4102),
|
||||
(42394.00, 2, 4452),
|
||||
(11726.00, 2, 7458),
|
||||
(39688.00, 2, 27969),
|
||||
(37884.00, 2, 28900),
|
||||
(9922.00, 2, 30278),
|
||||
(12628.00, 2, 30597),
|
||||
(7216.00, 2, 33058),
|
||||
(41492.00, 2, 37026),
|
||||
(40590.00, 2, 37123),
|
||||
(36982.00, 2, 39809),
|
||||
(36080.00, 2, 41415),
|
||||
(18942.00, 2, 42147),
|
||||
(24354.00, 2, 42533),
|
||||
(41492.00, 2, 43650),
|
||||
(45100.00, 2, 44103),
|
||||
(17138.00, 2, 46913),
|
||||
(31570.00, 2, 50499),
|
||||
(37884.00, 2, 54086),
|
||||
(26158.00, 2, 54436),
|
||||
(4510.00, 2, 54436),
|
||||
(3608.00, 2, 54630),
|
||||
(41492.00, 2, 55136),
|
||||
);
|
||||
|
||||
#
|
||||
# Unpartitioned
|
||||
#
|
||||
|
||||
# Single functions
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice
|
||||
----
|
||||
29733.00 1 2883 1314442.00
|
||||
1802.00 1 5121 1314442.00
|
||||
4505.00 1 6179 1314442.00
|
||||
29733.00 1 6273 1314442.00
|
||||
30634.00 1 8645 1314442.00
|
||||
41446.00 1 12005 1314442.00
|
||||
36040.00 1 16135 1314442.00
|
||||
29733.00 1 16198 1314442.00
|
||||
26129.00 1 20199 1314442.00
|
||||
24327.00 1 22117 1314442.00
|
||||
19822.00 1 24866 1314442.00
|
||||
24327.00 1 26756 1314442.00
|
||||
9010.00 1 27558 1314442.00
|
||||
45050.00 1 29859 1314442.00
|
||||
2703.00 1 34692 1314442.00
|
||||
11713.00 1 36611 1314442.00
|
||||
18020.00 1 38051 1314442.00
|
||||
21624.00 1 42465 1314442.00
|
||||
36040.00 1 42758 1314442.00
|
||||
39644.00 1 47620 1314442.00
|
||||
28832.00 1 50498 1314442.00
|
||||
12614.00 1 51970 1314442.00
|
||||
2703.00 1 53189 1314442.00
|
||||
22525.00 1 53825 1314442.00
|
||||
21624.00 1 54592 1314442.00
|
||||
36941.00 1 59202 1314442.00
|
||||
18942.00 2 548 1314442.00
|
||||
17138.00 2 807 1314442.00
|
||||
24354.00 2 2117 1314442.00
|
||||
9020.00 2 2528 1314442.00
|
||||
28864.00 2 4102 1314442.00
|
||||
42394.00 2 4452 1314442.00
|
||||
11726.00 2 7458 1314442.00
|
||||
39688.00 2 27969 1314442.00
|
||||
37884.00 2 28900 1314442.00
|
||||
9922.00 2 30278 1314442.00
|
||||
12628.00 2 30597 1314442.00
|
||||
7216.00 2 33058 1314442.00
|
||||
41492.00 2 37026 1314442.00
|
||||
40590.00 2 37123 1314442.00
|
||||
36982.00 2 39809 1314442.00
|
||||
36080.00 2 41415 1314442.00
|
||||
18942.00 2 42147 1314442.00
|
||||
24354.00 2 42533 1314442.00
|
||||
41492.00 2 43650 1314442.00
|
||||
45100.00 2 44103 1314442.00
|
||||
17138.00 2 46913 1314442.00
|
||||
31570.00 2 50499 1314442.00
|
||||
37884.00 2 54086 1314442.00
|
||||
4510.00 2 54436 1314442.00
|
||||
26158.00 2 54436 1314442.00
|
||||
3608.00 2 54630 1314442.00
|
||||
41492.00 2 55136 1314442.00
|
||||
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(order by l_partkey),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice
|
||||
----
|
||||
29733.00 1 2883 607274.00
|
||||
1802.00 1 5121 607274.00
|
||||
4505.00 1 6179 607274.00
|
||||
29733.00 1 6273 607274.00
|
||||
30634.00 1 8645 607274.00
|
||||
41446.00 1 12005 607274.00
|
||||
36040.00 1 16135 607274.00
|
||||
29733.00 1 16198 607274.00
|
||||
26129.00 1 20199 607274.00
|
||||
24327.00 1 22117 607274.00
|
||||
19822.00 1 24866 607274.00
|
||||
24327.00 1 26756 607274.00
|
||||
9010.00 1 27558 607274.00
|
||||
45050.00 1 29859 607274.00
|
||||
2703.00 1 34692 607274.00
|
||||
11713.00 1 36611 607274.00
|
||||
18020.00 1 38051 607274.00
|
||||
21624.00 1 42465 607274.00
|
||||
36040.00 1 42758 607274.00
|
||||
39644.00 1 47620 607274.00
|
||||
28832.00 1 50498 607274.00
|
||||
12614.00 1 51970 607274.00
|
||||
2703.00 1 53189 607274.00
|
||||
22525.00 1 53825 607274.00
|
||||
21624.00 1 54592 607274.00
|
||||
36941.00 1 59202 607274.00
|
||||
18942.00 2 548 1314442.00
|
||||
17138.00 2 807 1314442.00
|
||||
24354.00 2 2117 1314442.00
|
||||
9020.00 2 2528 1314442.00
|
||||
28864.00 2 4102 1314442.00
|
||||
42394.00 2 4452 1314442.00
|
||||
11726.00 2 7458 1314442.00
|
||||
39688.00 2 27969 1314442.00
|
||||
37884.00 2 28900 1314442.00
|
||||
9922.00 2 30278 1314442.00
|
||||
12628.00 2 30597 1314442.00
|
||||
7216.00 2 33058 1314442.00
|
||||
41492.00 2 37026 1314442.00
|
||||
40590.00 2 37123 1314442.00
|
||||
36982.00 2 39809 1314442.00
|
||||
36080.00 2 41415 1314442.00
|
||||
18942.00 2 42147 1314442.00
|
||||
24354.00 2 42533 1314442.00
|
||||
41492.00 2 43650 1314442.00
|
||||
45100.00 2 44103 1314442.00
|
||||
17138.00 2 46913 1314442.00
|
||||
31570.00 2 50499 1314442.00
|
||||
37884.00 2 54086 1314442.00
|
||||
4510.00 2 54436 1314442.00
|
||||
26158.00 2 54436 1314442.00
|
||||
3608.00 2 54630 1314442.00
|
||||
41492.00 2 55136 1314442.00
|
||||
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(order by l_partkey, l_orderkey),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 29733.00
|
||||
1802.00 1 5121 31535.00
|
||||
4505.00 1 6179 36040.00
|
||||
29733.00 1 6273 65773.00
|
||||
30634.00 1 8645 96407.00
|
||||
41446.00 1 12005 137853.00
|
||||
36040.00 1 16135 173893.00
|
||||
29733.00 1 16198 203626.00
|
||||
26129.00 1 20199 229755.00
|
||||
24327.00 1 22117 254082.00
|
||||
19822.00 1 24866 273904.00
|
||||
24327.00 1 26756 298231.00
|
||||
9010.00 1 27558 307241.00
|
||||
45050.00 1 29859 352291.00
|
||||
2703.00 1 34692 354994.00
|
||||
11713.00 1 36611 366707.00
|
||||
18020.00 1 38051 384727.00
|
||||
21624.00 1 42465 406351.00
|
||||
36040.00 1 42758 442391.00
|
||||
39644.00 1 47620 482035.00
|
||||
28832.00 1 50498 510867.00
|
||||
12614.00 1 51970 523481.00
|
||||
2703.00 1 53189 526184.00
|
||||
22525.00 1 53825 548709.00
|
||||
21624.00 1 54592 570333.00
|
||||
36941.00 1 59202 607274.00
|
||||
18942.00 2 548 626216.00
|
||||
17138.00 2 807 643354.00
|
||||
24354.00 2 2117 667708.00
|
||||
9020.00 2 2528 676728.00
|
||||
28864.00 2 4102 705592.00
|
||||
42394.00 2 4452 747986.00
|
||||
11726.00 2 7458 759712.00
|
||||
39688.00 2 27969 799400.00
|
||||
37884.00 2 28900 837284.00
|
||||
9922.00 2 30278 847206.00
|
||||
12628.00 2 30597 859834.00
|
||||
7216.00 2 33058 867050.00
|
||||
41492.00 2 37026 908542.00
|
||||
40590.00 2 37123 949132.00
|
||||
36982.00 2 39809 986114.00
|
||||
36080.00 2 41415 1022194.00
|
||||
18942.00 2 42147 1041136.00
|
||||
24354.00 2 42533 1065490.00
|
||||
41492.00 2 43650 1106982.00
|
||||
45100.00 2 44103 1152082.00
|
||||
17138.00 2 46913 1169220.00
|
||||
31570.00 2 50499 1200790.00
|
||||
37884.00 2 54086 1238674.00
|
||||
26158.00 2 54436 1269342.00
|
||||
4510.00 2 54436 1269342.00
|
||||
3608.00 2 54630 1272950.00
|
||||
41492.00 2 55136 1314442.00
|
||||
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(order by l_partkey, l_orderkey desc),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 607274.00
|
||||
1802.00 1 5121 577541.00
|
||||
4505.00 1 6179 575739.00
|
||||
29733.00 1 6273 571234.00
|
||||
30634.00 1 8645 541501.00
|
||||
41446.00 1 12005 510867.00
|
||||
36040.00 1 16135 469421.00
|
||||
29733.00 1 16198 433381.00
|
||||
26129.00 1 20199 403648.00
|
||||
24327.00 1 22117 377519.00
|
||||
19822.00 1 24866 353192.00
|
||||
24327.00 1 26756 333370.00
|
||||
9010.00 1 27558 309043.00
|
||||
45050.00 1 29859 300033.00
|
||||
2703.00 1 34692 254983.00
|
||||
11713.00 1 36611 252280.00
|
||||
18020.00 1 38051 240567.00
|
||||
21624.00 1 42465 222547.00
|
||||
36040.00 1 42758 200923.00
|
||||
39644.00 1 47620 164883.00
|
||||
28832.00 1 50498 125239.00
|
||||
12614.00 1 51970 96407.00
|
||||
2703.00 1 53189 83793.00
|
||||
22525.00 1 53825 81090.00
|
||||
21624.00 1 54592 58565.00
|
||||
36941.00 1 59202 36941.00
|
||||
18942.00 2 548 1314442.00
|
||||
17138.00 2 807 1295500.00
|
||||
24354.00 2 2117 1278362.00
|
||||
9020.00 2 2528 1254008.00
|
||||
28864.00 2 4102 1244988.00
|
||||
42394.00 2 4452 1216124.00
|
||||
11726.00 2 7458 1173730.00
|
||||
39688.00 2 27969 1162004.00
|
||||
37884.00 2 28900 1122316.00
|
||||
9922.00 2 30278 1084432.00
|
||||
12628.00 2 30597 1074510.00
|
||||
7216.00 2 33058 1061882.00
|
||||
41492.00 2 37026 1054666.00
|
||||
40590.00 2 37123 1013174.00
|
||||
36982.00 2 39809 972584.00
|
||||
36080.00 2 41415 935602.00
|
||||
18942.00 2 42147 899522.00
|
||||
24354.00 2 42533 880580.00
|
||||
41492.00 2 43650 856226.00
|
||||
45100.00 2 44103 814734.00
|
||||
17138.00 2 46913 769634.00
|
||||
31570.00 2 50499 752496.00
|
||||
37884.00 2 54086 720926.00
|
||||
26158.00 2 54436 683042.00
|
||||
4510.00 2 54436 683042.00
|
||||
3608.00 2 54630 652374.00
|
||||
41492.00 2 55136 648766.00
|
||||
|
||||
# Combined
|
||||
query IIIIIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(),
|
||||
sum(l_extendedprice) over(order by l_partkey),
|
||||
sum(l_extendedprice) over(order by l_partkey, l_orderkey),
|
||||
sum(l_extendedprice) over(order by l_partkey, l_orderkey desc),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 1314442.00 607274.00 29733.00 607274.00
|
||||
1802.00 1 5121 1314442.00 607274.00 31535.00 577541.00
|
||||
4505.00 1 6179 1314442.00 607274.00 36040.00 575739.00
|
||||
29733.00 1 6273 1314442.00 607274.00 65773.00 571234.00
|
||||
30634.00 1 8645 1314442.00 607274.00 96407.00 541501.00
|
||||
41446.00 1 12005 1314442.00 607274.00 137853.00 510867.00
|
||||
36040.00 1 16135 1314442.00 607274.00 173893.00 469421.00
|
||||
29733.00 1 16198 1314442.00 607274.00 203626.00 433381.00
|
||||
26129.00 1 20199 1314442.00 607274.00 229755.00 403648.00
|
||||
24327.00 1 22117 1314442.00 607274.00 254082.00 377519.00
|
||||
19822.00 1 24866 1314442.00 607274.00 273904.00 353192.00
|
||||
24327.00 1 26756 1314442.00 607274.00 298231.00 333370.00
|
||||
9010.00 1 27558 1314442.00 607274.00 307241.00 309043.00
|
||||
45050.00 1 29859 1314442.00 607274.00 352291.00 300033.00
|
||||
2703.00 1 34692 1314442.00 607274.00 354994.00 254983.00
|
||||
11713.00 1 36611 1314442.00 607274.00 366707.00 252280.00
|
||||
18020.00 1 38051 1314442.00 607274.00 384727.00 240567.00
|
||||
21624.00 1 42465 1314442.00 607274.00 406351.00 222547.00
|
||||
36040.00 1 42758 1314442.00 607274.00 442391.00 200923.00
|
||||
39644.00 1 47620 1314442.00 607274.00 482035.00 164883.00
|
||||
28832.00 1 50498 1314442.00 607274.00 510867.00 125239.00
|
||||
12614.00 1 51970 1314442.00 607274.00 523481.00 96407.00
|
||||
2703.00 1 53189 1314442.00 607274.00 526184.00 83793.00
|
||||
22525.00 1 53825 1314442.00 607274.00 548709.00 81090.00
|
||||
21624.00 1 54592 1314442.00 607274.00 570333.00 58565.00
|
||||
36941.00 1 59202 1314442.00 607274.00 607274.00 36941.00
|
||||
18942.00 2 548 1314442.00 1314442.00 626216.00 1314442.00
|
||||
17138.00 2 807 1314442.00 1314442.00 643354.00 1295500.00
|
||||
24354.00 2 2117 1314442.00 1314442.00 667708.00 1278362.00
|
||||
9020.00 2 2528 1314442.00 1314442.00 676728.00 1254008.00
|
||||
28864.00 2 4102 1314442.00 1314442.00 705592.00 1244988.00
|
||||
42394.00 2 4452 1314442.00 1314442.00 747986.00 1216124.00
|
||||
11726.00 2 7458 1314442.00 1314442.00 759712.00 1173730.00
|
||||
39688.00 2 27969 1314442.00 1314442.00 799400.00 1162004.00
|
||||
37884.00 2 28900 1314442.00 1314442.00 837284.00 1122316.00
|
||||
9922.00 2 30278 1314442.00 1314442.00 847206.00 1084432.00
|
||||
12628.00 2 30597 1314442.00 1314442.00 859834.00 1074510.00
|
||||
7216.00 2 33058 1314442.00 1314442.00 867050.00 1061882.00
|
||||
41492.00 2 37026 1314442.00 1314442.00 908542.00 1054666.00
|
||||
40590.00 2 37123 1314442.00 1314442.00 949132.00 1013174.00
|
||||
36982.00 2 39809 1314442.00 1314442.00 986114.00 972584.00
|
||||
36080.00 2 41415 1314442.00 1314442.00 1022194.00 935602.00
|
||||
18942.00 2 42147 1314442.00 1314442.00 1041136.00 899522.00
|
||||
24354.00 2 42533 1314442.00 1314442.00 1065490.00 880580.00
|
||||
41492.00 2 43650 1314442.00 1314442.00 1106982.00 856226.00
|
||||
45100.00 2 44103 1314442.00 1314442.00 1152082.00 814734.00
|
||||
17138.00 2 46913 1314442.00 1314442.00 1169220.00 769634.00
|
||||
31570.00 2 50499 1314442.00 1314442.00 1200790.00 752496.00
|
||||
37884.00 2 54086 1314442.00 1314442.00 1238674.00 720926.00
|
||||
26158.00 2 54436 1314442.00 1314442.00 1269342.00 683042.00
|
||||
4510.00 2 54436 1314442.00 1314442.00 1269342.00 683042.00
|
||||
3608.00 2 54630 1314442.00 1314442.00 1272950.00 652374.00
|
||||
41492.00 2 55136 1314442.00 1314442.00 1314442.00 648766.00
|
||||
|
||||
#
|
||||
# Partitioned
|
||||
#
|
||||
|
||||
# Single functions
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(partition by l_partkey),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 607274.00
|
||||
1802.00 1 5121 607274.00
|
||||
4505.00 1 6179 607274.00
|
||||
29733.00 1 6273 607274.00
|
||||
30634.00 1 8645 607274.00
|
||||
41446.00 1 12005 607274.00
|
||||
36040.00 1 16135 607274.00
|
||||
29733.00 1 16198 607274.00
|
||||
26129.00 1 20199 607274.00
|
||||
24327.00 1 22117 607274.00
|
||||
19822.00 1 24866 607274.00
|
||||
24327.00 1 26756 607274.00
|
||||
9010.00 1 27558 607274.00
|
||||
45050.00 1 29859 607274.00
|
||||
2703.00 1 34692 607274.00
|
||||
11713.00 1 36611 607274.00
|
||||
18020.00 1 38051 607274.00
|
||||
21624.00 1 42465 607274.00
|
||||
36040.00 1 42758 607274.00
|
||||
39644.00 1 47620 607274.00
|
||||
28832.00 1 50498 607274.00
|
||||
12614.00 1 51970 607274.00
|
||||
2703.00 1 53189 607274.00
|
||||
22525.00 1 53825 607274.00
|
||||
21624.00 1 54592 607274.00
|
||||
36941.00 1 59202 607274.00
|
||||
18942.00 2 548 707168.00
|
||||
17138.00 2 807 707168.00
|
||||
24354.00 2 2117 707168.00
|
||||
9020.00 2 2528 707168.00
|
||||
28864.00 2 4102 707168.00
|
||||
42394.00 2 4452 707168.00
|
||||
11726.00 2 7458 707168.00
|
||||
39688.00 2 27969 707168.00
|
||||
37884.00 2 28900 707168.00
|
||||
9922.00 2 30278 707168.00
|
||||
12628.00 2 30597 707168.00
|
||||
7216.00 2 33058 707168.00
|
||||
41492.00 2 37026 707168.00
|
||||
40590.00 2 37123 707168.00
|
||||
36982.00 2 39809 707168.00
|
||||
36080.00 2 41415 707168.00
|
||||
18942.00 2 42147 707168.00
|
||||
24354.00 2 42533 707168.00
|
||||
41492.00 2 43650 707168.00
|
||||
45100.00 2 44103 707168.00
|
||||
17138.00 2 46913 707168.00
|
||||
31570.00 2 50499 707168.00
|
||||
37884.00 2 54086 707168.00
|
||||
26158.00 2 54436 707168.00
|
||||
4510.00 2 54436 707168.00
|
||||
3608.00 2 54630 707168.00
|
||||
41492.00 2 55136 707168.00
|
||||
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(partition by l_partkey order by l_orderkey),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 29733.00
|
||||
1802.00 1 5121 31535.00
|
||||
4505.00 1 6179 36040.00
|
||||
29733.00 1 6273 65773.00
|
||||
30634.00 1 8645 96407.00
|
||||
41446.00 1 12005 137853.00
|
||||
36040.00 1 16135 173893.00
|
||||
29733.00 1 16198 203626.00
|
||||
26129.00 1 20199 229755.00
|
||||
24327.00 1 22117 254082.00
|
||||
19822.00 1 24866 273904.00
|
||||
24327.00 1 26756 298231.00
|
||||
9010.00 1 27558 307241.00
|
||||
45050.00 1 29859 352291.00
|
||||
2703.00 1 34692 354994.00
|
||||
11713.00 1 36611 366707.00
|
||||
18020.00 1 38051 384727.00
|
||||
21624.00 1 42465 406351.00
|
||||
36040.00 1 42758 442391.00
|
||||
39644.00 1 47620 482035.00
|
||||
28832.00 1 50498 510867.00
|
||||
12614.00 1 51970 523481.00
|
||||
2703.00 1 53189 526184.00
|
||||
22525.00 1 53825 548709.00
|
||||
21624.00 1 54592 570333.00
|
||||
36941.00 1 59202 607274.00
|
||||
18942.00 2 548 18942.00
|
||||
17138.00 2 807 36080.00
|
||||
24354.00 2 2117 60434.00
|
||||
9020.00 2 2528 69454.00
|
||||
28864.00 2 4102 98318.00
|
||||
42394.00 2 4452 140712.00
|
||||
11726.00 2 7458 152438.00
|
||||
39688.00 2 27969 192126.00
|
||||
37884.00 2 28900 230010.00
|
||||
9922.00 2 30278 239932.00
|
||||
12628.00 2 30597 252560.00
|
||||
7216.00 2 33058 259776.00
|
||||
41492.00 2 37026 301268.00
|
||||
40590.00 2 37123 341858.00
|
||||
36982.00 2 39809 378840.00
|
||||
36080.00 2 41415 414920.00
|
||||
18942.00 2 42147 433862.00
|
||||
24354.00 2 42533 458216.00
|
||||
41492.00 2 43650 499708.00
|
||||
45100.00 2 44103 544808.00
|
||||
17138.00 2 46913 561946.00
|
||||
31570.00 2 50499 593516.00
|
||||
37884.00 2 54086 631400.00
|
||||
26158.00 2 54436 662068.00
|
||||
4510.00 2 54436 662068.00
|
||||
3608.00 2 54630 665676.00
|
||||
41492.00 2 55136 707168.00
|
||||
|
||||
query IIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(partition by l_partkey order by l_orderkey desc),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 607274.00
|
||||
1802.00 1 5121 577541.00
|
||||
4505.00 1 6179 575739.00
|
||||
29733.00 1 6273 571234.00
|
||||
30634.00 1 8645 541501.00
|
||||
41446.00 1 12005 510867.00
|
||||
36040.00 1 16135 469421.00
|
||||
29733.00 1 16198 433381.00
|
||||
26129.00 1 20199 403648.00
|
||||
24327.00 1 22117 377519.00
|
||||
19822.00 1 24866 353192.00
|
||||
24327.00 1 26756 333370.00
|
||||
9010.00 1 27558 309043.00
|
||||
45050.00 1 29859 300033.00
|
||||
2703.00 1 34692 254983.00
|
||||
11713.00 1 36611 252280.00
|
||||
18020.00 1 38051 240567.00
|
||||
21624.00 1 42465 222547.00
|
||||
36040.00 1 42758 200923.00
|
||||
39644.00 1 47620 164883.00
|
||||
28832.00 1 50498 125239.00
|
||||
12614.00 1 51970 96407.00
|
||||
2703.00 1 53189 83793.00
|
||||
22525.00 1 53825 81090.00
|
||||
21624.00 1 54592 58565.00
|
||||
36941.00 1 59202 36941.00
|
||||
18942.00 2 548 707168.00
|
||||
17138.00 2 807 688226.00
|
||||
24354.00 2 2117 671088.00
|
||||
9020.00 2 2528 646734.00
|
||||
28864.00 2 4102 637714.00
|
||||
42394.00 2 4452 608850.00
|
||||
11726.00 2 7458 566456.00
|
||||
39688.00 2 27969 554730.00
|
||||
37884.00 2 28900 515042.00
|
||||
9922.00 2 30278 477158.00
|
||||
12628.00 2 30597 467236.00
|
||||
7216.00 2 33058 454608.00
|
||||
41492.00 2 37026 447392.00
|
||||
40590.00 2 37123 405900.00
|
||||
36982.00 2 39809 365310.00
|
||||
36080.00 2 41415 328328.00
|
||||
18942.00 2 42147 292248.00
|
||||
24354.00 2 42533 273306.00
|
||||
41492.00 2 43650 248952.00
|
||||
45100.00 2 44103 207460.00
|
||||
17138.00 2 46913 162360.00
|
||||
31570.00 2 50499 145222.00
|
||||
37884.00 2 54086 113652.00
|
||||
26158.00 2 54436 75768.00
|
||||
4510.00 2 54436 75768.00
|
||||
3608.00 2 54630 45100.00
|
||||
41492.00 2 55136 41492.00
|
||||
|
||||
# Combined
|
||||
query IIIIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(partition by l_partkey),
|
||||
sum(l_extendedprice) over(partition by l_partkey order by l_orderkey),
|
||||
sum(l_extendedprice) over(partition by l_partkey order by l_orderkey desc),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 607274.00 29733.00 607274.00
|
||||
1802.00 1 5121 607274.00 31535.00 577541.00
|
||||
4505.00 1 6179 607274.00 36040.00 575739.00
|
||||
29733.00 1 6273 607274.00 65773.00 571234.00
|
||||
30634.00 1 8645 607274.00 96407.00 541501.00
|
||||
41446.00 1 12005 607274.00 137853.00 510867.00
|
||||
36040.00 1 16135 607274.00 173893.00 469421.00
|
||||
29733.00 1 16198 607274.00 203626.00 433381.00
|
||||
26129.00 1 20199 607274.00 229755.00 403648.00
|
||||
24327.00 1 22117 607274.00 254082.00 377519.00
|
||||
19822.00 1 24866 607274.00 273904.00 353192.00
|
||||
24327.00 1 26756 607274.00 298231.00 333370.00
|
||||
9010.00 1 27558 607274.00 307241.00 309043.00
|
||||
45050.00 1 29859 607274.00 352291.00 300033.00
|
||||
2703.00 1 34692 607274.00 354994.00 254983.00
|
||||
11713.00 1 36611 607274.00 366707.00 252280.00
|
||||
18020.00 1 38051 607274.00 384727.00 240567.00
|
||||
21624.00 1 42465 607274.00 406351.00 222547.00
|
||||
36040.00 1 42758 607274.00 442391.00 200923.00
|
||||
39644.00 1 47620 607274.00 482035.00 164883.00
|
||||
28832.00 1 50498 607274.00 510867.00 125239.00
|
||||
12614.00 1 51970 607274.00 523481.00 96407.00
|
||||
2703.00 1 53189 607274.00 526184.00 83793.00
|
||||
22525.00 1 53825 607274.00 548709.00 81090.00
|
||||
21624.00 1 54592 607274.00 570333.00 58565.00
|
||||
36941.00 1 59202 607274.00 607274.00 36941.00
|
||||
18942.00 2 548 707168.00 18942.00 707168.00
|
||||
17138.00 2 807 707168.00 36080.00 688226.00
|
||||
24354.00 2 2117 707168.00 60434.00 671088.00
|
||||
9020.00 2 2528 707168.00 69454.00 646734.00
|
||||
28864.00 2 4102 707168.00 98318.00 637714.00
|
||||
42394.00 2 4452 707168.00 140712.00 608850.00
|
||||
11726.00 2 7458 707168.00 152438.00 566456.00
|
||||
39688.00 2 27969 707168.00 192126.00 554730.00
|
||||
37884.00 2 28900 707168.00 230010.00 515042.00
|
||||
9922.00 2 30278 707168.00 239932.00 477158.00
|
||||
12628.00 2 30597 707168.00 252560.00 467236.00
|
||||
7216.00 2 33058 707168.00 259776.00 454608.00
|
||||
41492.00 2 37026 707168.00 301268.00 447392.00
|
||||
40590.00 2 37123 707168.00 341858.00 405900.00
|
||||
36982.00 2 39809 707168.00 378840.00 365310.00
|
||||
36080.00 2 41415 707168.00 414920.00 328328.00
|
||||
18942.00 2 42147 707168.00 433862.00 292248.00
|
||||
24354.00 2 42533 707168.00 458216.00 273306.00
|
||||
41492.00 2 43650 707168.00 499708.00 248952.00
|
||||
45100.00 2 44103 707168.00 544808.00 207460.00
|
||||
17138.00 2 46913 707168.00 561946.00 162360.00
|
||||
31570.00 2 50499 707168.00 593516.00 145222.00
|
||||
37884.00 2 54086 707168.00 631400.00 113652.00
|
||||
26158.00 2 54436 707168.00 662068.00 75768.00
|
||||
4510.00 2 54436 707168.00 662068.00 75768.00
|
||||
3608.00 2 54630 707168.00 665676.00 45100.00
|
||||
41492.00 2 55136 707168.00 707168.00 41492.00
|
||||
|
||||
#
|
||||
# Mixing partitioned and unpartitioned
|
||||
#
|
||||
query IIIIIII
|
||||
select
|
||||
l_extendedprice,
|
||||
l_partkey,
|
||||
l_orderkey,
|
||||
sum(l_extendedprice) over(),
|
||||
sum(l_extendedprice) over(order by l_partkey),
|
||||
sum(l_extendedprice) over(order by l_partkey, l_orderkey),
|
||||
sum(l_extendedprice) over(partition by l_partkey order by l_orderkey desc),
|
||||
from lineitem
|
||||
order by l_partkey, l_orderkey, l_extendedprice desc
|
||||
----
|
||||
29733.00 1 2883 1314442.00 607274.00 29733.00 607274.00
|
||||
1802.00 1 5121 1314442.00 607274.00 31535.00 577541.00
|
||||
4505.00 1 6179 1314442.00 607274.00 36040.00 575739.00
|
||||
29733.00 1 6273 1314442.00 607274.00 65773.00 571234.00
|
||||
30634.00 1 8645 1314442.00 607274.00 96407.00 541501.00
|
||||
41446.00 1 12005 1314442.00 607274.00 137853.00 510867.00
|
||||
36040.00 1 16135 1314442.00 607274.00 173893.00 469421.00
|
||||
29733.00 1 16198 1314442.00 607274.00 203626.00 433381.00
|
||||
26129.00 1 20199 1314442.00 607274.00 229755.00 403648.00
|
||||
24327.00 1 22117 1314442.00 607274.00 254082.00 377519.00
|
||||
19822.00 1 24866 1314442.00 607274.00 273904.00 353192.00
|
||||
24327.00 1 26756 1314442.00 607274.00 298231.00 333370.00
|
||||
9010.00 1 27558 1314442.00 607274.00 307241.00 309043.00
|
||||
45050.00 1 29859 1314442.00 607274.00 352291.00 300033.00
|
||||
2703.00 1 34692 1314442.00 607274.00 354994.00 254983.00
|
||||
11713.00 1 36611 1314442.00 607274.00 366707.00 252280.00
|
||||
18020.00 1 38051 1314442.00 607274.00 384727.00 240567.00
|
||||
21624.00 1 42465 1314442.00 607274.00 406351.00 222547.00
|
||||
36040.00 1 42758 1314442.00 607274.00 442391.00 200923.00
|
||||
39644.00 1 47620 1314442.00 607274.00 482035.00 164883.00
|
||||
28832.00 1 50498 1314442.00 607274.00 510867.00 125239.00
|
||||
12614.00 1 51970 1314442.00 607274.00 523481.00 96407.00
|
||||
2703.00 1 53189 1314442.00 607274.00 526184.00 83793.00
|
||||
22525.00 1 53825 1314442.00 607274.00 548709.00 81090.00
|
||||
21624.00 1 54592 1314442.00 607274.00 570333.00 58565.00
|
||||
36941.00 1 59202 1314442.00 607274.00 607274.00 36941.00
|
||||
18942.00 2 548 1314442.00 1314442.00 626216.00 707168.00
|
||||
17138.00 2 807 1314442.00 1314442.00 643354.00 688226.00
|
||||
24354.00 2 2117 1314442.00 1314442.00 667708.00 671088.00
|
||||
9020.00 2 2528 1314442.00 1314442.00 676728.00 646734.00
|
||||
28864.00 2 4102 1314442.00 1314442.00 705592.00 637714.00
|
||||
42394.00 2 4452 1314442.00 1314442.00 747986.00 608850.00
|
||||
11726.00 2 7458 1314442.00 1314442.00 759712.00 566456.00
|
||||
39688.00 2 27969 1314442.00 1314442.00 799400.00 554730.00
|
||||
37884.00 2 28900 1314442.00 1314442.00 837284.00 515042.00
|
||||
9922.00 2 30278 1314442.00 1314442.00 847206.00 477158.00
|
||||
12628.00 2 30597 1314442.00 1314442.00 859834.00 467236.00
|
||||
7216.00 2 33058 1314442.00 1314442.00 867050.00 454608.00
|
||||
41492.00 2 37026 1314442.00 1314442.00 908542.00 447392.00
|
||||
40590.00 2 37123 1314442.00 1314442.00 949132.00 405900.00
|
||||
36982.00 2 39809 1314442.00 1314442.00 986114.00 365310.00
|
||||
36080.00 2 41415 1314442.00 1314442.00 1022194.00 328328.00
|
||||
18942.00 2 42147 1314442.00 1314442.00 1041136.00 292248.00
|
||||
24354.00 2 42533 1314442.00 1314442.00 1065490.00 273306.00
|
||||
41492.00 2 43650 1314442.00 1314442.00 1106982.00 248952.00
|
||||
45100.00 2 44103 1314442.00 1314442.00 1152082.00 207460.00
|
||||
17138.00 2 46913 1314442.00 1314442.00 1169220.00 162360.00
|
||||
31570.00 2 50499 1314442.00 1314442.00 1200790.00 145222.00
|
||||
37884.00 2 54086 1314442.00 1314442.00 1238674.00 113652.00
|
||||
26158.00 2 54436 1314442.00 1314442.00 1269342.00 75768.00
|
||||
4510.00 2 54436 1314442.00 1314442.00 1269342.00 75768.00
|
||||
3608.00 2 54630 1314442.00 1314442.00 1272950.00 45100.00
|
||||
41492.00 2 55136 1314442.00 1314442.00 1314442.00 41492.00
|
||||
14500
external/duckdb/test/sql/window/test_window_groups.test
vendored
Normal file
14500
external/duckdb/test/sql/window/test_window_groups.test
vendored
Normal file
File diff suppressed because it is too large
Load Diff
34
external/duckdb/test/sql/window/test_window_interval.test
vendored
Normal file
34
external/duckdb/test/sql/window/test_window_interval.test
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# name: test/sql/window/test_window_interval.test
|
||||
# description: Test window functions with intervals
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# interval as group
|
||||
statement ok
|
||||
create table a as select case when range%2==0 then interval '1 year' else interval '2 years' end j, range::integer AS i from range(1, 5, 1)
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over () from a order by 1,2
|
||||
----
|
||||
1 year 2 10
|
||||
1 year 4 10
|
||||
2 years 1 10
|
||||
2 years 3 10
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j) from a order by 1,2
|
||||
----
|
||||
1 year 2 6
|
||||
1 year 4 6
|
||||
2 years 1 4
|
||||
2 years 3 4
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j order by i) from a order by 1,2
|
||||
----
|
||||
1 year 2 2
|
||||
1 year 4 6
|
||||
2 years 1 1
|
||||
2 years 3 4
|
||||
47
external/duckdb/test/sql/window/test_window_order_collate.test
vendored
Normal file
47
external/duckdb/test/sql/window/test_window_order_collate.test
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# name: test/sql/window/test_window_order_collate.test
|
||||
# description: Test collation is honoured by over(partition/order by)
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query III rowsort
|
||||
select
|
||||
*,
|
||||
array_agg(col) over(partition by id order by col collate nocase) as lead_col_nocase
|
||||
from (
|
||||
select
|
||||
unnest(array[1, 1, 1, 1]) as id,
|
||||
unnest(array['A', 'a', 'b', 'B']) as col
|
||||
)
|
||||
----
|
||||
1 A [A, a]
|
||||
1 B [A, a, b, B]
|
||||
1 a [A, a]
|
||||
1 b [A, a, b, B]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE db_city (name VARCHAR, city VARCHAR COLLATE NOCASE);
|
||||
|
||||
statement ok
|
||||
INSERT INTO db_city VALUES
|
||||
('DuckDB', 'Amsterdam'),
|
||||
('MonetDB','amsterdam'),
|
||||
('VectorWise', 'Amstërdam');
|
||||
|
||||
|
||||
query III rowsort
|
||||
SELECT name, city, row_number() OVER (PARTITION BY city) AS row_id
|
||||
FROM db_city;
|
||||
----
|
||||
DuckDB Amsterdam 1
|
||||
MonetDB amsterdam 2
|
||||
VectorWise Amstërdam 1
|
||||
|
||||
query III rowsort
|
||||
SELECT name, city, row_number() OVER (PARTITION BY city COLLATE NOCASE) AS row_id
|
||||
FROM db_city;
|
||||
----
|
||||
DuckDB Amsterdam 1
|
||||
MonetDB amsterdam 2
|
||||
VectorWise Amstërdam 1
|
||||
9315
external/duckdb/test/sql/window/test_window_range.test
vendored
Normal file
9315
external/duckdb/test/sql/window/test_window_range.test
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
external/duckdb/test/sql/window/test_window_repartition.test_slow
vendored
Normal file
27
external/duckdb/test/sql/window/test_window_repartition.test_slow
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# name: test/sql/window/test_window_repartition.test_slow
|
||||
# description: Window reparitioning at scale
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=10
|
||||
|
||||
statement ok
|
||||
create table df as
|
||||
select d, i v1
|
||||
from
|
||||
range(date '2017-01-01', date '2020-12-31', interval '1' day) t(d),
|
||||
range(3000) i
|
||||
;
|
||||
|
||||
query I
|
||||
select count(*)
|
||||
from (
|
||||
select percent_rank() over (partition by d order by v1) as rank_v1
|
||||
from df
|
||||
);
|
||||
----
|
||||
4380000
|
||||
|
||||
2786
external/duckdb/test/sql/window/test_window_rows.test
vendored
Normal file
2786
external/duckdb/test/sql/window/test_window_rows.test
vendored
Normal file
File diff suppressed because it is too large
Load Diff
89
external/duckdb/test/sql/window/test_window_sort.test_slow
vendored
Normal file
89
external/duckdb/test/sql/window/test_window_sort.test_slow
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# name: test/sql/window/test_window_sort.test_slow
|
||||
# description: Compare window function sorting with ORDER BY sorting on TPC-H's lineitem
|
||||
# group: [window]
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
statement ok
|
||||
CALL dbgen(sf=1);
|
||||
|
||||
statement ok
|
||||
pragma verify_parallelism
|
||||
|
||||
# derive table from lineitem that has a deterministic sorting order on l_extendedprice
|
||||
statement ok
|
||||
CREATE TABLE lineitem_d AS (
|
||||
SELECT DISTINCT ON (l_extendedprice) *
|
||||
FROM lineitem
|
||||
);
|
||||
|
||||
# first iteration runs externally, second runs normally
|
||||
statement ok
|
||||
PRAGMA debug_force_external=true
|
||||
|
||||
loop i 0 2
|
||||
|
||||
# use lag to find rows that are out of place
|
||||
query IIIIIIIIIIIIIIIII nosort q0
|
||||
with lineitem_ord as (select * from lineitem_d order by l_extendedprice),
|
||||
lag_window as (select *, case when l_extendedprice < lag(l_extendedprice) over () then 1 else 0 end incorrect_order from lineitem_ord)
|
||||
select * from lag_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query IIIIIIIIIIIIIIIII nosort q0
|
||||
with lag_window as (select *, case when l_extendedprice < lag(l_extendedprice) over (order by l_extendedprice) then 1 else 0 end incorrect_order from lineitem_d)
|
||||
select * from lag_window order by l_extendedprice
|
||||
----
|
||||
|
||||
# compare order with window function order (structs)
|
||||
query III nosort q1
|
||||
with lineitem_ord as (select * from lineitem_d order by l_extendedprice),
|
||||
rownum_window as (select l_extendedprice, struct_pack(sd:=l_shipdate, cd:=l_commitdate, rd:=l_receiptdate), row_number() over () from lineitem_ord)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query III nosort q1
|
||||
with rownum_window as (select l_extendedprice, struct_pack(sd:=l_shipdate, cd:=l_commitdate, rd:=l_receiptdate), row_number() over (order by l_extendedprice) from lineitem_d)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query III nosort q2
|
||||
with lineitem_ord as (select * from lineitem_d order by l_extendedprice),
|
||||
rownum_window as (select l_extendedprice, struct_pack(si:=l_shipinstruct, sm:=l_shipmode, c:=l_comment), row_number() over () from lineitem_ord)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query III nosort q2
|
||||
with rownum_window as (select l_extendedprice, struct_pack(si:=l_shipinstruct, sm:=l_shipmode, c:=l_comment), row_number() over (order by l_extendedprice) from lineitem_d)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
# compare order with window function order (lists)
|
||||
query IIIII nosort q3
|
||||
with lineitem_ord as (select * from lineitem_d order by l_extendedprice),
|
||||
rownum_window as (select l_extendedprice, list_value(l_shipdate), list_value(l_commitdate), list_value(l_receiptdate), row_number() over () from lineitem_ord)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query IIIII nosort q3
|
||||
select l_extendedprice, list_value(l_shipdate), list_value(l_commitdate), list_value(l_receiptdate), row_number() over (order by l_extendedprice) from lineitem_d;
|
||||
----
|
||||
|
||||
query IIIII nosort q4
|
||||
with lineitem_ord as (select * from lineitem_d order by l_extendedprice),
|
||||
rownum_window as (select l_extendedprice, list_value(l_shipinstruct), list_value(l_shipmode), list_value(l_comment), row_number() over () from lineitem_ord)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
query IIIII nosort q4
|
||||
with rownum_window as (select l_extendedprice, list_value(l_shipinstruct), list_value(l_shipmode), list_value(l_comment), row_number() over (order by l_extendedprice) from lineitem_d)
|
||||
select * from rownum_window order by l_extendedprice
|
||||
----
|
||||
|
||||
statement ok
|
||||
PRAGMA debug_force_external=false
|
||||
|
||||
endloop
|
||||
37
external/duckdb/test/sql/window/test_window_string_agg.test
vendored
Normal file
37
external/duckdb/test/sql/window/test_window_string_agg.test
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# name: test/sql/window/test_window_string_agg.test
|
||||
# description: Test string_agg with window functions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table a as select range%3 j, range::varchar AS s, case when range%3=0 then '-' else '|' end sep from range(1, 7, 1)
|
||||
|
||||
# regular string_agg
|
||||
query III
|
||||
select j, s, string_agg(s) over (partition by j order by s) from a order by j, s;
|
||||
----
|
||||
0 3 3
|
||||
0 6 3,6
|
||||
1 1 1
|
||||
1 4 1,4
|
||||
2 2 2
|
||||
2 5 2,5
|
||||
|
||||
# custom separator
|
||||
query III
|
||||
select j, s, string_agg(s, '|') over (partition by j order by s) from a order by j, s;
|
||||
----
|
||||
0 3 3
|
||||
0 6 3|6
|
||||
1 1 1
|
||||
1 4 1|4
|
||||
2 2 2
|
||||
2 5 2|5
|
||||
|
||||
# different separator per group
|
||||
statement error
|
||||
select j, s, string_agg(s, sep) over (partition by j order by s) from a order by j, s;
|
||||
----
|
||||
<REGEX>:.*Binder Error.*Separator.* must be a constant.*
|
||||
59
external/duckdb/test/sql/window/test_window_tpcds.test
vendored
Normal file
59
external/duckdb/test/sql/window/test_window_tpcds.test
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# name: test/sql/window/test_window_tpcds.test
|
||||
# description: TPC-DS inspired micro benchmarks
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE item(i_category VARCHAR, i_brand VARCHAR, i_price INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO item VALUES ('toys', 'fisher-price', 100)
|
||||
|
||||
query TTRI
|
||||
SELECT i_category, i_brand, avg(sum(i_price)) OVER (PARTITION BY i_category), rank() OVER (PARTITION BY i_category ORDER BY i_category, i_brand) rn FROM item GROUP BY i_category, i_brand;
|
||||
----
|
||||
toys fisher-price 100.000000 1
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
CREATE TABLE item(i_category VARCHAR, i_brand VARCHAR, i_item_sk INTEGER);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE store(s_store_name VARCHAR, s_company_name VARCHAR, s_store_sk INTEGER);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE date_dim(d_year INTEGER, d_moy INTEGER, d_date_sk INTEGER);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE store_sales(ss_sales_price DECIMAL, ss_item_sk INTEGER, ss_sold_date_sk INTEGER, ss_store_sk INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO item VALUES ('Music', 'exportischolar', 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO store VALUES ('ought', 'Unknown', 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO date_dim VALUES (1999, 1, 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO store_sales VALUES (2.8, 1, 1, 1);
|
||||
|
||||
query TTTTIIRRI
|
||||
SELECT i_category, i_brand, s_store_name, s_company_name, d_year, d_moy, sum(ss_sales_price) sum_sales, avg(sum(ss_sales_price)) OVER (PARTITION BY i_category, i_brand, s_store_name, s_company_name, d_year) avg_monthly_sales, rank() OVER (PARTITION BY i_category, i_brand, s_store_name, s_company_name ORDER BY d_year, d_moy) rn FROM item, store_sales, date_dim, store WHERE ss_item_sk = i_item_sk AND ss_sold_date_sk = d_date_sk AND ss_store_sk = s_store_sk AND (d_year = 1999 OR (d_year = 1999-1 AND d_moy =12) OR (d_year = 1999+1 AND d_moy =1)) GROUP BY i_category, i_brand, s_store_name, s_company_name, d_year, d_moy;
|
||||
----
|
||||
Music exportischolar ought Unknown 1999 1 2.800000 2.800000 1
|
||||
|
||||
statement ok
|
||||
ROLLBACK
|
||||
|
||||
46
external/duckdb/test/sql/window/test_window_types.test
vendored
Normal file
46
external/duckdb/test/sql/window/test_window_types.test
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# name: test/sql/window/test_window_types.test
|
||||
# description: Test window functions with different types
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
foreach type <numeric>
|
||||
|
||||
statement ok
|
||||
create table a as select range%3::${type} j, range::${type} AS i from range(1, 7, 1)
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over () from a order by 1,2
|
||||
----
|
||||
0 3 21
|
||||
0 6 21
|
||||
1 1 21
|
||||
1 4 21
|
||||
2 2 21
|
||||
2 5 21
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j) from a order by 1,2
|
||||
----
|
||||
0 3 9
|
||||
0 6 9
|
||||
1 1 5
|
||||
1 4 5
|
||||
2 2 7
|
||||
2 5 7
|
||||
|
||||
query III
|
||||
select j, i, sum(i) over (partition by j order by i) from a order by 1,2
|
||||
----
|
||||
0 3 3
|
||||
0 6 9
|
||||
1 1 1
|
||||
1 4 5
|
||||
2 2 2
|
||||
2 5 7
|
||||
|
||||
statement ok
|
||||
drop table a
|
||||
|
||||
endloop
|
||||
53
external/duckdb/test/sql/window/test_window_unnest_error.test
vendored
Normal file
53
external/duckdb/test/sql/window/test_window_unnest_error.test
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# name: test/sql/window/test_window_unnest_error.test
|
||||
# description: Test window functions with UNNEST expressions
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl AS SELECT 42 AS i;
|
||||
|
||||
# START_EXPR
|
||||
statement error
|
||||
SELECT SUM(i) OVER (ROWS BETWEEN UNNEST([1]) PRECEDING AND 1 FOLLOWING) FROM tbl;
|
||||
----
|
||||
UNNEST not supported here
|
||||
|
||||
# END_EXPR
|
||||
statement error
|
||||
SELECT SUM(i) OVER (ROWS BETWEEN 1 PRECEDING AND UNNEST([1]) FOLLOWING) FROM tbl;
|
||||
----
|
||||
UNNEST not supported here
|
||||
|
||||
# OFFSET_EXPR
|
||||
statement error
|
||||
SELECT lead(c0, UNNEST([1])) OVER (ROWS BETWEEN 2 PRECEDING AND 4 PRECEDING)
|
||||
FROM (VALUES (1, 2)) a(c0);
|
||||
----
|
||||
UNNEST not supported here
|
||||
|
||||
# FILTER_EXPR
|
||||
statement error
|
||||
SELECT x, count(x) FILTER (WHERE x % 2 = UNNEST([2])) OVER (ORDER BY x ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
|
||||
FROM generate_series(0, 10) tbl(x);
|
||||
----
|
||||
UNNEST not supported here
|
||||
|
||||
# DEFAULT_EXPR
|
||||
statement error
|
||||
SELECT lead(c0, 0, UNNEST([1])) OVER (ROWS BETWEEN 2 PRECEDING AND 4 PRECEDING)
|
||||
FROM (VALUES (1, 2)) a(c0);
|
||||
----
|
||||
UNNEST not supported here
|
||||
|
||||
# We allow UNNEST in subqueries.
|
||||
|
||||
query I
|
||||
SELECT SUM(i) OVER (ROWS BETWEEN (SELECT UNNEST([1])) PRECEDING AND 1 FOLLOWING) FROM tbl;
|
||||
----
|
||||
42
|
||||
|
||||
query I
|
||||
SELECT lead(c0, (SELECT UNNEST([0])), (SELECT UNNEST([1]))) OVER (ROWS BETWEEN 2 PRECEDING AND 4 PRECEDING)
|
||||
FROM (VALUES (1, 2)) a(c0);
|
||||
----
|
||||
1
|
||||
|
||||
61
external/duckdb/test/sql/window/test_window_walmart.test_slow
vendored
Normal file
61
external/duckdb/test/sql/window/test_window_walmart.test_slow
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# name: test/sql/window/test_window_walmart.test_slow
|
||||
# description: Parallel window lag
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "data" ("Store" INTEGER, "Dept" INTEGER, "Date" DATE, "Weekly_Sales" DOUBLE, "IsHoliday" BOOLEAN);
|
||||
|
||||
statement ok
|
||||
insert into data select * from read_csv_auto('test/sql/window/walmart.csv.gz');
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=4
|
||||
|
||||
statement ok
|
||||
SELECT
|
||||
*,
|
||||
lag(Weekly_Sales, 1) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_1,
|
||||
lag(Weekly_Sales, 2) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_2,
|
||||
lag(Weekly_Sales, 3) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_3,
|
||||
lag(Weekly_Sales, 4) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_4,
|
||||
lag(Weekly_Sales, 5) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_5,
|
||||
lag(Weekly_Sales, 6) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_6,
|
||||
lag(Weekly_Sales, 7) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_7,
|
||||
lag(Weekly_Sales, 8) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_8,
|
||||
lag(Weekly_Sales, 9) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_9,
|
||||
lag(Weekly_Sales, 10) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_10
|
||||
FROM
|
||||
data;
|
||||
|
||||
statement ok
|
||||
SELECT
|
||||
*,
|
||||
lag(Weekly_Sales, 1) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_1,
|
||||
lag(Weekly_Sales, 2) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_2,
|
||||
lag(Weekly_Sales, 3) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_3,
|
||||
lag(Weekly_Sales, 4) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_4,
|
||||
lag(Weekly_Sales, 5) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_5,
|
||||
lag(Weekly_Sales, 6) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_6,
|
||||
lag(Weekly_Sales, 7) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_7,
|
||||
lag(Weekly_Sales, 8) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_8,
|
||||
lag(Weekly_Sales, 9) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_9,
|
||||
lag(Weekly_Sales, 10) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_10
|
||||
FROM
|
||||
data;
|
||||
|
||||
|
||||
statement ok
|
||||
SELECT
|
||||
*,
|
||||
lag(Weekly_Sales, 1) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_1,
|
||||
lag(Weekly_Sales, 2) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_2,
|
||||
lag(Weekly_Sales, 3) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_3,
|
||||
lag(Weekly_Sales, 4) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_4,
|
||||
lag(Weekly_Sales, 5) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_5,
|
||||
lag(Weekly_Sales, 6) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_6,
|
||||
lag(Weekly_Sales, 7) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_7,
|
||||
lag(Weekly_Sales, 8) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_8,
|
||||
lag(Weekly_Sales, 9) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_9,
|
||||
lag(Weekly_Sales, 10) OVER(PARTITION BY "Store", "Dept" ORDER BY "Date" ASC) AS Lag_10
|
||||
FROM
|
||||
data;
|
||||
25
external/duckdb/test/sql/window/test_window_wide_frame.test_slow
vendored
Normal file
25
external/duckdb/test/sql/window/test_window_wide_frame.test_slow
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# name: test/sql/window/test_window_wide_frame.test_slow
|
||||
# description: Test wide temporal range frames
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
set seed 0.618033
|
||||
|
||||
statement ok
|
||||
CREATE TABLE flog AS
|
||||
SELECT (random() * 100)::INTEGER AS laufzeit
|
||||
, TIMESTAMP '2020-10-15 16:45:00' + INTERVAL (random() * 15 * 60) SECOND AS "timestamp"
|
||||
FROM range(26000);
|
||||
|
||||
query III
|
||||
select timestamp
|
||||
, median(laufzeit) over w
|
||||
, count(*) over w
|
||||
from flog
|
||||
window w as (order by timestamp asc range between interval 55 seconds preceding and interval 58 seconds following)
|
||||
order by 3 desc, 1
|
||||
limit 1;
|
||||
----
|
||||
2020-10-15 16:54:37.416129 49.5 3376
|
||||
320
external/duckdb/test/sql/window/test_window_wisconsin.test
vendored
Normal file
320
external/duckdb/test/sql/window/test_window_wisconsin.test
vendored
Normal file
@@ -0,0 +1,320 @@
|
||||
# name: test/sql/window/test_window_wisconsin.test
|
||||
# description: Wisconsin-derived window test cases
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tenk1 (unique1 int4, unique2 int4, two int4, four int4, ten int4, twenty int4, hundred int4, thousand int4, twothousand int4, fivethous int4, tenthous int4, odd int4, even int4, stringu1 varchar, stringu2 varchar, string4 varchar)
|
||||
|
||||
statement ok
|
||||
insert into tenk1 values (8800,0,0,0,0,0,0,800,800,3800,8800,0,1,'MAAAAA','AAAAAA','AAAAxx'), (1891,1,1,3,1,11,91,891,1891,1891,1891,182,183,'TUAAAA','BAAAAA','HHHHxx'), (3420,2,0,0,0,0,20,420,1420,3420,3420,40,41,'OBAAAA','CAAAAA','OOOOxx'), (9850,3,0,2,0,10,50,850,1850,4850,9850,100,101,'WOAAAA','DAAAAA','VVVVxx'), (7164,4,0,0,4,4,64,164,1164,2164,7164,128,129,'OPAAAA','EAAAAA','AAAAxx'), (8009,5,1,1,9,9,9,9,9,3009,8009,18,19,'BWAAAA','FAAAAA','HHHHxx'), (5057,6,1,1,7,17,57,57,1057,57,5057,114,115,'NMAAAA','GAAAAA','OOOOxx'), (6701,7,1,1,1,1,1,701,701,1701,6701,2,3,'TXAAAA','HAAAAA','VVVVxx'), (4321,8,1,1,1,1,21,321,321,4321,4321,42,43,'FKAAAA','IAAAAA','AAAAxx'), (3043,9,1,3,3,3,43,43,1043,3043,3043,86,87,'BNAAAA','JAAAAA','HHHHxx')
|
||||
|
||||
query I
|
||||
SELECT COUNT(*) OVER () FROM tenk1
|
||||
----
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
10
|
||||
|
||||
query RII
|
||||
SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 order by ten, unique2
|
||||
----
|
||||
0.000000 0 0
|
||||
0.000000 0 0
|
||||
2.000000 0 2
|
||||
3.000000 1 3
|
||||
4.000000 1 1
|
||||
5.000000 1 1
|
||||
3.000000 3 3
|
||||
0.000000 4 0
|
||||
1.000000 7 1
|
||||
1.000000 9 1
|
||||
|
||||
query I
|
||||
SELECT row_number() OVER (ORDER BY unique2) rn FROM tenk1 WHERE unique2 < 10 ORDER BY rn
|
||||
----
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
|
||||
query III
|
||||
SELECT rank() OVER (PARTITION BY four ORDER BY ten) AS rank_1, ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten
|
||||
----
|
||||
1 0 0
|
||||
1 0 0
|
||||
3 4 0
|
||||
1 1 1
|
||||
1 1 1
|
||||
3 7 1
|
||||
4 9 1
|
||||
1 0 2
|
||||
1 1 3
|
||||
2 3 3
|
||||
|
||||
query I
|
||||
SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten) FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten
|
||||
----
|
||||
1
|
||||
1
|
||||
2
|
||||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
1
|
||||
2
|
||||
|
||||
query I
|
||||
SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten) FROM tenk1 WHERE unique2 < 10 order by four, ten
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
0
|
||||
1
|
||||
1
|
||||
|
||||
# percent_rank
|
||||
query I
|
||||
SELECT cast(percent_rank() OVER (PARTITION BY four ORDER BY ten)*10 as INTEGER) FROM tenk1 ORDER BY four, ten
|
||||
----
|
||||
0
|
||||
0
|
||||
10
|
||||
0
|
||||
0
|
||||
7
|
||||
10
|
||||
0
|
||||
0
|
||||
10
|
||||
|
||||
# cume_dist
|
||||
query I
|
||||
SELECT cast(cume_dist() OVER (PARTITION BY four ORDER BY ten)*10 as integer) FROM tenk1 WHERE unique2 < 10 order by four, ten
|
||||
----
|
||||
7
|
||||
7
|
||||
10
|
||||
5
|
||||
5
|
||||
8
|
||||
10
|
||||
10
|
||||
5
|
||||
10
|
||||
|
||||
# ntile
|
||||
query I
|
||||
SELECT ntile(2) OVER (ORDER BY ten, four) nn FROM tenk1 ORDER BY ten, four, nn
|
||||
----
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
|
||||
query I
|
||||
SELECT ntile(3) OVER (ORDER BY ten, four) nn FROM tenk1 ORDER BY ten, four, nn
|
||||
----
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
3
|
||||
|
||||
query I
|
||||
SELECT ntile(4) OVER (ORDER BY ten, four) nn FROM tenk1 ORDER BY ten, four, nn
|
||||
----
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
|
||||
query I
|
||||
SELECT ntile(5) OVER (ORDER BY ten, four) nn FROM tenk1 ORDER BY ten, four, nn
|
||||
----
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
|
||||
# lead/lag
|
||||
query I
|
||||
SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
NULL
|
||||
0
|
||||
0
|
||||
NULL
|
||||
1
|
||||
1
|
||||
7
|
||||
NULL
|
||||
NULL
|
||||
1
|
||||
|
||||
query I
|
||||
SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
4
|
||||
NULL
|
||||
1
|
||||
7
|
||||
9
|
||||
NULL
|
||||
NULL
|
||||
3
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
0
|
||||
4
|
||||
NULL
|
||||
1
|
||||
1
|
||||
7
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
0
|
||||
4
|
||||
0
|
||||
1
|
||||
1
|
||||
7
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
statement error
|
||||
SELECT lag(ten, four, 0, 0) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
<REGEX>:.*Parser Error.*Incorrect number of parameters.*
|
||||
|
||||
query I
|
||||
SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
4
|
||||
NULL
|
||||
1
|
||||
7
|
||||
9
|
||||
NULL
|
||||
NULL
|
||||
3
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
8
|
||||
NULL
|
||||
2
|
||||
14
|
||||
18
|
||||
NULL
|
||||
NULL
|
||||
6
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten) lt FROM tenk1 order by four, ten, lt
|
||||
----
|
||||
0
|
||||
8
|
||||
-1
|
||||
2
|
||||
14
|
||||
18
|
||||
-1
|
||||
-1
|
||||
6
|
||||
-1
|
||||
|
||||
# empty OVER clause
|
||||
query IRIIII
|
||||
SELECT COUNT(*) OVER w c, SUM(four) OVER w s, cast(AVG(ten) OVER w * 10 as integer) a, RANK() over w r, DENSE_RANK() over w dr, ROW_NUMBER() OVER w rn FROM tenk1 WINDOW w AS () ORDER BY rn
|
||||
----
|
||||
10 12.000000 26 1 1 1
|
||||
10 12.000000 26 1 1 2
|
||||
10 12.000000 26 1 1 3
|
||||
10 12.000000 26 1 1 4
|
||||
10 12.000000 26 1 1 5
|
||||
10 12.000000 26 1 1 6
|
||||
10 12.000000 26 1 1 7
|
||||
10 12.000000 26 1 1 8
|
||||
10 12.000000 26 1 1 9
|
||||
10 12.000000 26 1 1 10
|
||||
|
||||
# no ordering but still a frame spec (somewhat underdefined)
|
||||
query IRIIII
|
||||
SELECT COUNT(*) OVER w c, SUM(four) OVER w s, cast(AVG(ten) OVER w * 10 as integer) a, RANK() over w r, DENSE_RANK() over w dr, ROW_NUMBER() OVER w rn FROM tenk1 WINDOW w AS (rows between 1 preceding and 1 following) ORDER BY rn
|
||||
----
|
||||
2 3 5 1 1 1
|
||||
3 3 3 1 1 2
|
||||
3 5 3 1 1 3
|
||||
3 2 13 1 1 4
|
||||
3 3 43 1 1 5
|
||||
3 2 67 1 1 6
|
||||
3 3 57 1 1 7
|
||||
3 3 30 1 1 8
|
||||
3 5 17 1 1 9
|
||||
2 4 20 1 1 10
|
||||
BIN
external/duckdb/test/sql/window/walmart.csv.gz
vendored
Normal file
BIN
external/duckdb/test/sql/window/walmart.csv.gz
vendored
Normal file
Binary file not shown.
145
external/duckdb/test/sql/window/window_mtcars.test
vendored
Normal file
145
external/duckdb/test/sql/window/window_mtcars.test
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
# name: test/sql/window/window_mtcars.test
|
||||
# description: Test window function without
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE mtcars (mpg DECIMAL, cyl INTEGER, disp DECIMAL, hp INTEGER, drat DECIMAL, wt DECIMAL, qsec DECIMAL, vs INTEGER, am INTEGER, gear INTEGER, carb INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('21.0', '6', '160.0', '110', '3.90', '2.620', '16.46', '0', '1', '4', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('21.0', '6', '160.0', '110', '3.90', '2.875', '17.02', '0', '1', '4', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('22.8', '4', '108.0', '93', '3.85', '2.320', '18.61', '1', '1', '4', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('21.4', '6', '258.0', '110', '3.08', '3.215', '19.44', '1', '0', '3', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('18.7', '8', '360.0', '175', '3.15', '3.440', '17.02', '0', '0', '3', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('18.1', '6', '225.0', '105', '2.76', '3.460', '20.22', '1', '0', '3', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('14.3', '8', '360.0', '245', '3.21', '3.570', '15.84', '0', '0', '3', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('24.4', '4', '146.7', '62', '3.69', '3.190', '20.00', '1', '0', '4', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('22.8', '4', '140.8', '95', '3.92', '3.150', '22.90', '1', '0', '4', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('19.2', '6', '167.6', '123', '3.92', '3.440', '18.30', '1', '0', '4', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('17.8', '6', '167.6', '123', '3.92', '3.440', '18.90', '1', '0', '4', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('16.4', '8', '275.8', '180', '3.07', '4.070', '17.40', '0', '0', '3', '3');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('17.3', '8', '275.8', '180', '3.07', '3.730', '17.60', '0', '0', '3', '3');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('15.2', '8', '275.8', '180', '3.07', '3.780', '18.00', '0', '0', '3', '3');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('10.4', '8', '472.0', '205', '2.93', '5.250', '17.98', '0', '0', '3', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('10.4', '8', '460.0', '215', '3.00', '5.424', '17.82', '0', '0', '3', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('14.7', '8', '440.0', '230', '3.23', '5.345', '17.42', '0', '0', '3', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('32.4', '4', '78.7', '66', '4.08', '2.200', '19.47', '1', '1', '4', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('30.4', '4', '75.7', '52', '4.93', '1.615', '18.52', '1', '1', '4', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('33.9', '4', '71.1', '65', '4.22', '1.835', '19.90', '1', '1', '4', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('21.5', '4', '120.1', '97', '3.70', '2.465', '20.01', '1', '0', '3', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('15.5', '8', '318.0', '150', '2.76', '3.520', '16.87', '0', '0', '3', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('15.2', '8', '304.0', '150', '3.15', '3.435', '17.30', '0', '0', '3', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('13.3', '8', '350.0', '245', '3.73', '3.840', '15.41', '0', '0', '3', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('19.2', '8', '400.0', '175', '3.08', '3.845', '17.05', '0', '0', '3', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('27.3', '4', '79.0', '66', '4.08', '1.935', '18.90', '1', '1', '4', '1');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('26.0', '4', '120.3', '91', '4.43', '2.140', '16.70', '0', '1', '5', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('30.4', '4', '95.1', '113', '3.77', '1.513', '16.90', '1', '1', '5', '2');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('15.8', '8', '351.0', '264', '4.22', '3.170', '14.50', '0', '1', '5', '4');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('19.7', '6', '145.0', '175', '3.62', '2.770', '15.50', '0', '1', '5', '6');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('15.0', '8', '301.0', '335', '3.54', '3.570', '14.60', '0', '1', '5', '8');
|
||||
|
||||
statement ok
|
||||
INSERT INTO mtcars VALUES ('21.4', '4', '121.0', '109', '4.11', '2.780', '18.60', '1', '1', '4', '2');
|
||||
|
||||
query TT
|
||||
SELECT
|
||||
mpg,
|
||||
SUM(mpg) OVER (ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS mpg_roll
|
||||
FROM
|
||||
mtcars
|
||||
----
|
||||
21.000 21.000
|
||||
21.000 42.000
|
||||
22.800 43.800
|
||||
21.400 44.200
|
||||
18.700 40.100
|
||||
18.100 36.800
|
||||
14.300 32.400
|
||||
24.400 38.700
|
||||
22.800 47.200
|
||||
19.200 42.000
|
||||
17.800 37.000
|
||||
16.400 34.200
|
||||
17.300 33.700
|
||||
15.200 32.500
|
||||
10.400 25.600
|
||||
10.400 20.800
|
||||
14.700 25.100
|
||||
32.400 47.100
|
||||
30.400 62.800
|
||||
33.900 64.300
|
||||
21.500 55.400
|
||||
15.500 37.000
|
||||
15.200 30.700
|
||||
13.300 28.500
|
||||
19.200 32.500
|
||||
27.300 46.500
|
||||
26.000 53.300
|
||||
30.400 56.400
|
||||
15.800 46.200
|
||||
19.700 35.500
|
||||
15.000 34.700
|
||||
21.400 36.400
|
||||
36
external/duckdb/test/sql/window/window_partition_paging.test_slow
vendored
Normal file
36
external/duckdb/test/sql/window/window_partition_paging.test_slow
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# name: test/sql/window/window_partition_paging.test_slow
|
||||
# description: test paging in constrained memory
|
||||
# group: [window]
|
||||
|
||||
require 64bit
|
||||
|
||||
statement ok
|
||||
CREATE or replace TABLE big_table AS
|
||||
SELECT
|
||||
(i % 500)::int16 AS "Pid",
|
||||
(i % 5000)::int16 AS "Planid",
|
||||
left(uuid()::VARCHAR, 10) AS "Claimid",
|
||||
FROM range(2e7::int) tbl(i);
|
||||
|
||||
statement ok
|
||||
PRAGMA temp_directory='__TEST_DIR__/window_paging'
|
||||
|
||||
# This query would take ~2.5GB of memory
|
||||
statement ok
|
||||
PRAGMA memory_limit='1GB'
|
||||
|
||||
statement ok
|
||||
PRAGMA verify_external
|
||||
|
||||
query II
|
||||
WITH new_table as (SELECT
|
||||
Pid,
|
||||
Planid,
|
||||
Claimid,
|
||||
'CLAIM' || dense_rank() OVER(PARTITION BY Pid, Planid ORDER BY Claimid) AS Fake_Claimid
|
||||
FROM big_table
|
||||
)
|
||||
SELECT MAX(Fake_Claimid), COUNT(*)
|
||||
FROM new_table
|
||||
----
|
||||
CLAIM999 20000000
|
||||
35
external/duckdb/test/sql/window/window_rolling_summation.test_slow
vendored
Normal file
35
external/duckdb/test/sql/window/window_rolling_summation.test_slow
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# name: test/sql/window/window_rolling_summation.test_slow
|
||||
# description: Rolling summation (issue #965)
|
||||
# group: [window]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table temp as select * from range(0, 10000) temp(x);
|
||||
|
||||
query TTTTT
|
||||
SELECT *,
|
||||
expected=x_roll
|
||||
FROM
|
||||
(SELECT x,
|
||||
rowid,
|
||||
CASE WHEN x=0 THEN 0
|
||||
ELSE x*2-1
|
||||
END AS expected,
|
||||
SUM(x) OVER (ORDER BY rowid ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS x_roll
|
||||
FROM temp) t1(x)
|
||||
WHERE x BETWEEN 892 AND 902
|
||||
ORDER BY x;
|
||||
----
|
||||
892 892 1783 1783 1
|
||||
893 893 1785 1785 1
|
||||
894 894 1787 1787 1
|
||||
895 895 1789 1789 1
|
||||
896 896 1791 1791 1
|
||||
897 897 1793 1793 1
|
||||
898 898 1795 1795 1
|
||||
899 899 1797 1797 1
|
||||
900 900 1799 1799 1
|
||||
901 901 1801 1801 1
|
||||
902 902 1803 1803 1
|
||||
35
external/duckdb/test/sql/window/window_valid_end.test_slow
vendored
Normal file
35
external/duckdb/test/sql/window/window_valid_end.test_slow
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# name: test/sql/window/window_valid_end.test_slow
|
||||
# description: Nasty user test that stresses ValidEnd vectorisation.
|
||||
# group: [window]
|
||||
|
||||
# This only reproduced in release because debug wrote garbage instead of 0s...
|
||||
statement ok
|
||||
pragma threads=2;
|
||||
|
||||
loop i 1 100
|
||||
|
||||
query IIIIII
|
||||
select * from
|
||||
(
|
||||
select
|
||||
column0,
|
||||
sale_customer__id,
|
||||
year_total,
|
||||
next_year,
|
||||
sale_date__year,
|
||||
(
|
||||
first (year_total) over (
|
||||
partition by
|
||||
sale_customer__id
|
||||
order by
|
||||
sale_date__year
|
||||
range between 1 following and 1 following
|
||||
)
|
||||
) as recompute_next_year,
|
||||
from 'data/csv/issue_16098.csv'
|
||||
)
|
||||
where next_year is distinct from recompute_next_year
|
||||
order by all;
|
||||
----
|
||||
|
||||
endloop
|
||||
Reference in New Issue
Block a user