summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/range_pg/win_range_pgdate_case3.yql
blob: cbaa88ed8b5c12b5e4de96e19d4db5d614527dd0 (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
PRAGMA WindowNewPipeline;

$data = [
    <|a: pgdate('2017-11-25'), b: 1, count: 1|>,
    <|a: pgdate('2017-11-26'), b: 1, count: 2|>,
    <|a: pgdate('2017-11-27'), b: 1, count: 2|>,
    <|a: NULL, b: 1, count: 2|>,
    <|a: NULL, b: 1, count: 2|>,
];

$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 pginterval('1 day') PRECEDING AND CURRENT ROW
        )
);

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