summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/win_range_bound_decimal_current_row.yql
blob: d5e56b26269d1f9f19a8a5f890151a5d6f2320e9 (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: Decimal('nan', 3, 1), b: 1, expected_count: 2|>,
    <|a: Decimal('nan', 3, 1), b: 1, expected_count: 2|>,
    <|a: Decimal('+inf', 3, 1), b: 1, expected_count: 2|>,
    <|a: Decimal('+inf', 3, 1), b: 1, expected_count: 2|>,
    -- One step before inf.
    <|a: Decimal('99.9', 3, 1), b: 1, expected_count: 3|>,
    <|a: Decimal('4', 3, 1), b: 1, expected_count: 1|>,
    <|a: Decimal('2', 3, 1), b: 1, expected_count: 1|>,
    <|a: Decimal('1', 3, 1), b: 1, expected_count: 1|>,
    <|a: Decimal('-inf', 3, 1), b: 1, expected_count: 2|>,
    <|a: Decimal('-inf', 3, 1), b: 1, expected_count: 2|>,
];

$win_result = (
    SELECT
        COUNT(*) OVER w1 AS actual_count1,
        expected_count,
    FROM
        AS_TABLE($data)
    WINDOW
        w1 AS (
            PARTITION COMPACT BY
                b
            ORDER BY
                a DESC
            RANGE BETWEEN Decimal('0.1', 3, 1) PRECEDING AND CURRENT ROW
        )
);

select 
    ENSURE(actual_count1, actual_count1 IS NOT DISTINCT FROM expected_count, "Count differs")
from $win_result;