summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/win_range_interval.yql
blob: 1e2e72928f8c4250efac531a4844e11c98b2c49b (plain) (blame)
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
PRAGMA WindowNewPipeline;

$data = [
    <|a: Interval("P1DT2H3M4.567888S"), b: 1, count: 2|>,
    <|a: Interval("P1DT2H3M4.567889S"), b: 1, count: 1|>,
    <|a: Interval("P1DT2H3M4.567890S"), b: 1, count: 0|>,
    <|a: NULL, b: 1, count: 5|>,
    <|a: NULL, b: 1, count: 5|>,
];

$win_result = (
    SELECT
        COUNT(*) OVER w1 AS actual_count,
        count,
    FROM
        AS_TABLE($data)
    WINDOW
        w1 AS (
            PARTITION COMPACT BY
                b
            ORDER BY
                a ASC
            RANGE BETWEEN Interval("PT0.000001S") FOLLOWING AND UNBOUNDED FOLLOWING
        )
);

$str = ($x) -> {
    return CAST($x as String) ?? "null";
};

SELECT
    Ensure(actual_count, count IS NOT DISTINCT FROM actual_count, $str(actual_count))
FROM
    $win_result
;