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

$data = [
    <|a: TzDate("2024-01-01,Europe/Moscow"), count: 2|>,
    <|a: TzDate("2024-01-02,Europe/Moscow"), count: 3|>,
    <|a: TzDate("2024-01-03,Europe/Moscow"), count: 2|>,
    <|a: TzDate("2024-01-05,Europe/Moscow"), count: 2|>,
    <|a: TzDate("2024-01-06,Europe/Moscow"), count: 2|>,
];

$win_result = (
    SELECT
        COUNT(*) OVER w1 AS actual_count,
        count,
    FROM
        AS_TABLE($data)
    WINDOW
        w1 AS (
            ORDER BY
                a ASC
            RANGE BETWEEN Interval64("P1DT12H") PRECEDING AND Interval64("P1D") 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
;