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

$data = [
    <|a: NULL, b: 1, sum11: NULL, count: 0|>,
    <|a: NULL, b: 1, sum11: NULL, count: 0|>,
    <|a: pgint2('8'), b: 1, sum11: NULL, count: 0|>,
    <|a: pgint2('10'), b: 1, sum11: NULL, count: 0|>,
    <|a: pgint2('11'), b: 1, sum11: NULL, count: 0|>,
];

$win_result = (
    SELECT
        pg::sum(a) OVER w1 AS actual_sum11,
        COUNT(*) OVER w1 AS actual_count,
        sum11,
        count,
    FROM
        AS_TABLE($data)
    WINDOW
        w1 AS (
            PARTITION COMPACT BY
                b
            ORDER BY
                a ASC
            RANGE BETWEEN pgint2('1') PRECEDING AND pgint2('2') PRECEDING
        )
);

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