forked from feldera/feldera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_decimal_sum.py
More file actions
68 lines (56 loc) · 2.66 KB
/
Copy pathtest_decimal_sum.py
File metadata and controls
68 lines (56 loc) · 2.66 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from .aggtst_base import TstView
from decimal import Decimal
class aggtst_decimal_sum(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum AS SELECT
SUM(c1) AS c1, SUM(c2) AS c2
FROM decimal_tbl"""
self.data = [{"c1": Decimal("12473.68"), "c2": Decimal("21060.37")}]
class aggtst_decimal_sum_gby(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum_gby AS SELECT
id, SUM(c1) AS c1, SUM(c2) AS c2
FROM decimal_tbl
GROUP BY id"""
self.data = [
{"id": 0, "c1": Decimal("1111.52"), "c2": Decimal("6034.61")},
{"id": 1, "c1": Decimal("11362.16"), "c2": Decimal("15025.76")},
]
class aggtst_decimal_sum_distinct(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum_distinct AS SELECT
SUM(DISTINCT c1) AS c1, SUM(DISTINCT c2) AS c2
FROM decimal_tbl"""
self.data = [{"c1": Decimal("6792.60"), "c2": Decimal("21060.37")}]
class aggtst_decimal_sum_distinct_gby(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum_distinct_gby AS SELECT
id, SUM(DISTINCT c1) AS c1, SUM(DISTINCT c2) AS c2
FROM decimal_tbl
GROUP BY id"""
self.data = [
{"id": 0, "c1": Decimal("1111.52"), "c2": Decimal("6034.61")},
{"id": 1, "c1": Decimal("5681.08"), "c2": Decimal("15025.76")},
]
class aggtst_decimal_sum_where(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum_where AS SELECT
SUM(c1) FILTER(WHERE c2>2231.90) AS f_c1, SUM(c2) FILTER(WHERE c2>2231.90) AS f_c2
FROM decimal_tbl"""
self.data = [{"f_c1": Decimal("11362.16"), "f_c2": Decimal("18828.47")}]
class aggtst_decimal_sum_where_gby(TstView):
def __init__(self):
# Validated on Postgres
self.sql = """CREATE MATERIALIZED VIEW decimal_sum_where_gby AS SELECT
id, SUM(c1) FILTER(WHERE c2>2231.90) AS f_c1, SUM(c2) FILTER(WHERE c2>2231.90) AS f_c2
FROM decimal_tbl
GROUP BY id"""
self.data = [
{"id": 0, "f_c1": None, "f_c2": Decimal("3802.71")},
{"id": 1, "f_c1": Decimal("11362.16"), "f_c2": Decimal("15025.76")},
]