forked from duckdb/duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue duckdb#10885: Negative Window RANGEs
Detect and trap negative range boundaries to match PG behaviour. fixes: duckdb#10885 fixes: duckdblabs/duckdb-internal#1389
- Loading branch information
Richard Wesley
committed
Mar 27, 2024
1 parent
0465529
commit 9d7e958
Showing
2 changed files
with
111 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
|