-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(book): documentation for window rows vs range (#3634)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: eitsupi <ts1s1andn@gmail.com> (cherry picked from commit f2cd306)
- Loading branch information
1 parent
5f20f37
commit 69ccdb8
Showing
2 changed files
with
99 additions
and
3 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
50 changes: 50 additions & 0 deletions
50
...ion/snapshots/documentation__book__reference__stdlib__transforms__window__example__2.snap
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,50 @@ | ||
--- | ||
source: web/book/tests/documentation/book.rs | ||
expression: "from [\n {time_id=1, value=15},\n {time_id=2, value=11},\n {time_id=3, value=16},\n {time_id=4, value=9},\n {time_id=7, value=20},\n {time_id=8, value=22},\n]\nwindow rows:-2..0 (\n sort time_id\n derive {sma3rows = average value}\n)\nwindow range:-2..0 (\n sort time_id\n derive {sma3range = average value}\n)\n" | ||
--- | ||
WITH table_0 AS ( | ||
SELECT | ||
1 AS time_id, | ||
15 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
2 AS time_id, | ||
11 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
3 AS time_id, | ||
16 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
4 AS time_id, | ||
9 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
7 AS time_id, | ||
20 AS value | ||
UNION | ||
ALL | ||
SELECT | ||
8 AS time_id, | ||
22 AS value | ||
) | ||
SELECT | ||
time_id, | ||
value, | ||
AVG(value) OVER ( | ||
ORDER BY | ||
time_id ROWS BETWEEN 2 PRECEDING AND CURRENT ROW | ||
) AS sma3rows, | ||
AVG(value) OVER ( | ||
ORDER BY | ||
time_id RANGE BETWEEN 2 PRECEDING AND CURRENT ROW | ||
) AS sma3range | ||
FROM | ||
table_0 | ||
ORDER BY | ||
time_id | ||
|