Skip to content

Commit 36d634f

Browse files
committed
py: add illegal argument tests for aggregate functions
Signed-off-by: rivudhk <rivudhkr@gmail.com>
1 parent bd36eb2 commit 36d634f

File tree

2 files changed

+195
-0
lines changed

2 files changed

+195
-0
lines changed

python/tests/runtime_aggtest/illarg_tests/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from tests.runtime_aggtest.aggtst_base import * # noqa: F403
44
from tests.runtime_aggtest.atest_run import run # noqa: F403
55

6+
from test_agg import * # noqa: F403
67
from test_arr_map_type_fn import * # noqa: F403
78
from test_date_time_fn import * # noqa: F403
89
from test_numeric_type_fn import * # noqa: F403
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
from tests.runtime_aggtest.aggtst_base import TstView
2+
3+
4+
# ARRAY_AGG
5+
class illarg_arr_agg_illegal(TstView):
6+
def __init__(self):
7+
# checked manually
8+
self.sql = """CREATE MATERIALIZED VIEW illarg_arr_agg_illegal AS SELECT
9+
ARRAY_AGG(intt, intt) AS arr
10+
FROM illegal_tbl
11+
WHERE id = 0"""
12+
self.expected_error = "Invalid number of arguments to function 'ARRAY_AGG'. Was expecting 1 arguments"
13+
14+
15+
# AVG
16+
class illarg_avg_illegal(TstView):
17+
def __init__(self):
18+
# checked manually
19+
self.sql = """CREATE MATERIALIZED VIEW illarg_avg_illegal AS SELECT
20+
AVG(booll) AS arr
21+
FROM illegal_tbl
22+
WHERE id = 0"""
23+
self.expected_error = "Cannot apply 'AVG' to arguments of type"
24+
25+
26+
# ARG_MAX
27+
class illarg_arg_max_illegal(TstView):
28+
def __init__(self):
29+
# checked manually
30+
self.sql = """CREATE MATERIALIZED VIEW illarg_arg_max_illegal AS SELECT
31+
ARG_MAX(udt) AS udt
32+
FROM illegal_tbl"""
33+
self.expected_error = "Invalid number of arguments to function 'ARG_MAX'. Was expecting 2 arguments"
34+
35+
36+
# ARG_MIN
37+
class illarg_arg_min_illegal(TstView):
38+
def __init__(self):
39+
# checked manually
40+
self.sql = """CREATE MATERIALIZED VIEW illarg_arg_min_illegal AS SELECT
41+
ARG_MIN(roww, roww, roww) AS roww
42+
FROM illegal_tbl"""
43+
self.expected_error = "Invalid number of arguments to function 'ARG_MIN'. Was expecting 2 arguments"
44+
45+
46+
# BIT_AND
47+
class illarg_bit_and_illegal(TstView):
48+
def __init__(self):
49+
# checked manually
50+
self.sql = """CREATE MATERIALIZED VIEW illarg_bit_and_illegal AS SELECT
51+
BIT_AND(roww) AS roww
52+
FROM illegal_tbl"""
53+
self.expected_error = "Cannot apply 'BIT_AND' to arguments of type "
54+
55+
56+
# BIT_OR
57+
class illarg_bit_or_illegal(TstView):
58+
def __init__(self):
59+
self.sql = """CREATE MATERIALIZED VIEW illarg_bit_or_illegal AS SELECT
60+
BIT_OR(udt) AS udt
61+
FROM illegal_tbl"""
62+
self.expected_error = "Cannot apply 'BIT_OR' to arguments of type "
63+
64+
65+
# BIT_XOR
66+
class illarg_bit_xor_illegal(TstView):
67+
def __init__(self):
68+
self.sql = """CREATE MATERIALIZED VIEW illarg_bit_xor_illegal AS SELECT
69+
BIT_XOR(udt) AS udt
70+
FROM illegal_tbl"""
71+
self.expected_error = "Cannot apply 'BIT_XOR' to arguments of type "
72+
73+
74+
# COUNT
75+
class illarg_count_illegal(TstView):
76+
def __init__(self):
77+
# checked manually
78+
self.sql = """CREATE MATERIALIZED VIEW illarg_count_illegal AS SELECT
79+
COUNT(udt, COUNT(intt)) AS udt
80+
FROM illegal_tbl"""
81+
self.expected_error = "Aggregate expressions cannot be nested"
82+
83+
84+
# COUNTIF
85+
class illarg_countif_illegal(TstView):
86+
def __init__(self):
87+
# checked manually
88+
self.sql = """CREATE MATERIALIZED VIEW illarg_countif_illegal AS SELECT
89+
COUNTIF(reall < 0.2, decimall > 2) AS reall
90+
FROM illegal_tbl"""
91+
self.expected_error = "invalid number of arguments to function 'countif'"
92+
93+
94+
# EVERY
95+
class illarg_every_illegal(TstView):
96+
def __init__(self):
97+
# checked manually
98+
self.sql = """CREATE MATERIALIZED VIEW illarg_every_illegal AS SELECT
99+
EVERY(intt) AS intt
100+
FROM illegal_tbl"""
101+
self.expected_error = "Cannot apply 'EVERY' to arguments of type 'EVERY(<INTEGER>)'. Supported form(s): 'EVERY(<BOOLEAN>)'"
102+
103+
104+
# SOME
105+
class illarg_some_illegal(TstView):
106+
def __init__(self):
107+
# checked manually
108+
self.sql = """CREATE MATERIALIZED VIEW illarg_some_illegal AS SELECT
109+
SOME(intt) AS intt
110+
FROM illegal_tbl"""
111+
self.expected_error = "Cannot apply 'SOME' to arguments of type 'SOME(<INTEGER>)'. Supported form(s): 'SOME(<BOOLEAN>)'"
112+
113+
114+
# BOOL_AND
115+
class illarg_bool_and_illegal(TstView):
116+
def __init__(self):
117+
# checked manually
118+
self.sql = """CREATE MATERIALIZED VIEW illarg_bool_and_illegal AS SELECT
119+
BOOL_AND(udt[2] IS NOT NULL, arr[2] IS NOT NULL) AS udt
120+
FROM illegal_tbl"""
121+
self.expected_error = "Invalid number of arguments to function 'BOOL_AND'. Was expecting 1 arguments"
122+
123+
124+
# BOOL_OR
125+
class illarg_bool_or_illegal(TstView):
126+
def __init__(self):
127+
# checked manually
128+
self.sql = """CREATE MATERIALIZED VIEW illarg_bool_or_illegal AS SELECT
129+
BOOL_OR(arr[2] IS NOT NULL, arr[2] IS NOT NULL) AS arr
130+
FROM illegal_tbl"""
131+
self.expected_error = "Invalid number of arguments to function 'BOOL_OR'. Was expecting 1 arguments"
132+
133+
134+
# MAX
135+
class illarg_max_illegal(TstView):
136+
def __init__(self):
137+
# checked manually
138+
self.sql = """CREATE MATERIALIZED VIEW illarg_max_illegal AS SELECT
139+
MAX(udt[2], arr[2]) AS udt
140+
FROM illegal_tbl"""
141+
self.expected_error = (
142+
"Invalid number of arguments to function 'MAX'. Was expecting 1 arguments"
143+
)
144+
145+
146+
# MIN
147+
class illarg_min_illegal(TstView):
148+
def __init__(self):
149+
# checked manually
150+
self.sql = """CREATE MATERIALIZED VIEW illarg_min_illegal AS SELECT
151+
MIN(udt[2], arr[2]) AS udt
152+
FROM illegal_tbl"""
153+
self.expected_error = (
154+
"Invalid number of arguments to function 'MIN'. Was expecting 1 arguments"
155+
)
156+
157+
158+
# SUM
159+
class illarg_sum_illegal(TstView):
160+
def __init__(self):
161+
# checked manually
162+
self.sql = """CREATE MATERIALIZED VIEW illarg_sum_illegal AS SELECT
163+
SUM(udt) AS udt
164+
FROM illegal_tbl"""
165+
self.expected_error = "Cannot apply 'SUM' to arguments of type "
166+
167+
168+
class illarg_sum_illegal1(TstView):
169+
def __init__(self):
170+
# checked manually
171+
self.sql = """CREATE MATERIALIZED VIEW illarg_sum_illegal1 AS SELECT
172+
SUM(str) AS str
173+
FROM illegal_tbl"""
174+
self.expected_error = "Cannot parse hello into a DECIMAL(38, 19)"
175+
176+
177+
# STDDEV
178+
class illarg_stddev_illegal(TstView):
179+
def __init__(self):
180+
# checked manually
181+
self.sql = """CREATE MATERIALIZED VIEW illarg_stddev_illegal AS SELECT
182+
STDDEV(roww) AS roww
183+
FROM illegal_tbl"""
184+
self.expected_error = "Cannot apply 'STDDEV' to arguments of type "
185+
186+
187+
# STDDEV_POP
188+
class illarg_stddev_pop_illegal(TstView):
189+
def __init__(self):
190+
# checked manually
191+
self.sql = """CREATE MATERIALIZED VIEW illarg_stddev_pop_illegal AS SELECT
192+
STDDEV_POP(roww) AS roww
193+
FROM illegal_tbl"""
194+
self.expected_error = "Cannot apply 'STDDEV_POP' to arguments of type "

0 commit comments

Comments
 (0)