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

$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('1', 3, 1) PRECEDING AND Decimal('2', 3, 1) PRECEDING
        )
);

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