1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
PRAGMA WindowNewPipeline;
$data = [
<|a: Interval64("P1DT2H3M4.567888S"), b: 1, count1: 1, count2: 2|>,
<|a: Interval64("P1DT2H3M4.567889S"), b: 1, count1: 2, count2: 2|>,
<|a: Interval64("P1DT2H3M4.567890S"), b: 1, count1: 2, count2: 1|>,
<|a: NULL, b: 1, count1: 2, count2: 2|>,
<|a: NULL, b: 1, count1: 2, count2: 2|>,
];
$win_result = (
SELECT
COUNT(*) OVER w1 AS actual_count1,
COUNT(*) OVER w2 AS actual_count2,
count1,
count2,
FROM
AS_TABLE($data)
WINDOW
w1 AS (
PARTITION COMPACT BY
b
ORDER BY
a ASC
RANGE BETWEEN Interval64("PT0.000001S") PRECEDING AND CURRENT ROW
),
w2 AS (
PARTITION COMPACT BY
b
ORDER BY
a ASC
RANGE BETWEEN CURRENT ROW AND Interval64("PT0.000001S") FOLLOWING
)
);
$str = ($x) -> {
return CAST($x as String) ?? "null";
};
SELECT
Ensure(count1, count1 IS NOT DISTINCT FROM actual_count1, $str(actual_count1)),
Ensure(count2, count2 IS NOT DISTINCT FROM actual_count2, $str(actual_count2))
FROM
$win_result
;
|