should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View 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