Skip to content

Commit 267b6d3

Browse files
rivudhkmihaibudiu
authored andcommitted
py: add new negative arithmetic tests
Signed-off-by: rivudhk <rivudhkr@gmail.com>
1 parent 8a51c25 commit 267b6d3

1 file changed

Lines changed: 180 additions & 0 deletions

File tree

python/tests/runtime_aggtest/negative_tests/test_neg_arithmetic.py

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,183 @@ def __init__(self):
259259
self.expected_error = (
260260
"'4294966290 / 0' causes overflow for type INTEGER UNSIGNED"
261261
)
262+
263+
264+
# Subtraction
265+
class neg_sub_tiny_int(TstView):
266+
def __init__(self):
267+
# checked manually
268+
self.sql = """CREATE MATERIALIZED VIEW sub_tiny_int AS SELECT
269+
- tiny_int - tiny_int2 AS tiny_int
270+
FROM numeric_tbl
271+
WHERE id = 0"""
272+
self.expected_error = "'-120 - 100' causes overflow for type TINYINT"
273+
274+
275+
class neg_sub_small_int(TstView):
276+
def __init__(self):
277+
# checked manually
278+
self.sql = """CREATE MATERIALIZED VIEW sub_small_int AS SELECT
279+
- small_int - small_int2 AS small_int
280+
FROM numeric_tbl
281+
WHERE id = 0"""
282+
self.expected_error = "'-32750 - 32700' causes overflow for type SMALLINT"
283+
284+
285+
class neg_sub_big_int(TstView):
286+
def __init__(self):
287+
# checked manually
288+
self.sql = """CREATE MATERIALIZED VIEW sub_big_int AS SELECT
289+
- big_int - big_int2 AS big_int
290+
FROM numeric_tbl
291+
WHERE id = 0"""
292+
self.expected_error = "'-8123302036854775807 - 9223372036854775807' causes overflow for type BIGINT"
293+
294+
295+
class neg_sub_intt(TstView):
296+
def __init__(self):
297+
# checked manually
298+
self.sql = """CREATE MATERIALIZED VIEW sub_intt AS SELECT
299+
- intt - intt2 AS intt
300+
FROM numeric_tbl
301+
WHERE id = 0"""
302+
self.expected_error = (
303+
"'-2147483647 - 2147483000' causes overflow for type INTEGER"
304+
)
305+
306+
307+
class neg_sub_tiny_un_int(TstView):
308+
def __init__(self):
309+
# checked manually
310+
self.sql = """CREATE MATERIALIZED VIEW sub_tiny_un_int AS SELECT
311+
tiny_int2 - tiny_int AS tiny_un_int
312+
FROM numeric_un_tbl
313+
WHERE id = 0"""
314+
self.expected_error = "'200 - 250' causes overflow for type TINYINT UNSIGNED"
315+
316+
317+
class neg_sub_small_un_int(TstView):
318+
def __init__(self):
319+
# checked manually
320+
self.sql = """CREATE MATERIALIZED VIEW sub_small_int AS SELECT
321+
small_int - small_int2 AS small_un_int
322+
FROM numeric_un_tbl
323+
WHERE id = 0"""
324+
self.expected_error = (
325+
"'65430 - 65435' causes overflow for type SMALLINT UNSIGNED"
326+
)
327+
328+
329+
class neg_sub_big_un_int(TstView):
330+
def __init__(self):
331+
# checked manually
332+
self.sql = """CREATE MATERIALIZED VIEW sub_big_un_int AS SELECT
333+
big_int - big_int2 AS big_un_int
334+
FROM numeric_un_tbl
335+
WHERE id = 0"""
336+
self.expected_error = "'12446742073709541615 - 18446742073709541615' causes overflow for type BIGINT UNSIGNED"
337+
338+
339+
class neg_sub_un_intt(TstView):
340+
def __init__(self):
341+
# checked manually
342+
self.sql = """CREATE MATERIALIZED VIEW sub_un_intt AS SELECT
343+
intt2 - intt AS un_intt
344+
FROM numeric_un_tbl
345+
WHERE id = 0"""
346+
self.expected_error = (
347+
"'4292966290 - 4294966290' causes overflow for type INTEGER UNSIGNED"
348+
)
349+
350+
351+
# MOD
352+
class neg_mod_tiny_int(TstView):
353+
def __init__(self):
354+
# checked manually
355+
self.sql = """CREATE MATERIALIZED VIEW mod_tiny_int AS SELECT
356+
tiny_int % 0::TINYINT AS tiny_int
357+
FROM numeric_tbl
358+
WHERE id = 1"""
359+
self.expected_error = (
360+
"attempt to calculate the remainder with a divisor of zero"
361+
)
362+
363+
364+
class neg_mod_small_int(TstView):
365+
def __init__(self):
366+
# checked manually
367+
self.sql = """CREATE MATERIALIZED VIEW mod_small_int AS SELECT
368+
small_int % 0::SMALLINT AS small_int
369+
FROM numeric_tbl
370+
WHERE id = 1"""
371+
self.expected_error = (
372+
"attempt to calculate the remainder with a divisor of zero"
373+
)
374+
375+
376+
class neg_mod_big_int(TstView):
377+
def __init__(self):
378+
# checked manually
379+
self.sql = """CREATE MATERIALIZED VIEW mod_big_int AS SELECT
380+
big_int % 0::BIGINT AS big_int
381+
FROM numeric_tbl
382+
WHERE id = 1"""
383+
self.expected_error = (
384+
"attempt to calculate the remainder with a divisor of zero"
385+
)
386+
387+
388+
class neg_mod_intt(TstView):
389+
def __init__(self):
390+
# checked manually
391+
self.sql = """CREATE MATERIALIZED VIEW mod_intt AS SELECT
392+
intt % 0::INTEGER AS intt
393+
FROM numeric_tbl
394+
WHERE id = 1"""
395+
self.expected_error = (
396+
"attempt to calculate the remainder with a divisor of zero"
397+
)
398+
399+
400+
class neg_mod_tiny_un_int(TstView):
401+
def __init__(self):
402+
# checked manually
403+
self.sql = """CREATE MATERIALIZED VIEW mod_tiny_un_int AS SELECT
404+
tiny_int % 0::TINYINT UNSIGNED AS tiny_un_int
405+
FROM numeric_un_tbl"""
406+
self.expected_error = (
407+
"attempt to calculate the remainder with a divisor of zero"
408+
)
409+
410+
411+
class neg_mod_small_un_int(TstView):
412+
def __init__(self):
413+
# checked manually
414+
self.sql = """CREATE MATERIALIZED VIEW mod_small_un_int AS SELECT
415+
small_int % 0::SMALLINT UNSIGNED AS small_un_int
416+
FROM numeric_un_tbl"""
417+
self.expected_error = (
418+
"attempt to calculate the remainder with a divisor of zero"
419+
)
420+
421+
422+
class neg_mod_big_un_int(TstView):
423+
def __init__(self):
424+
# checked manually
425+
self.sql = """CREATE MATERIALIZED VIEW mod_big_un_int AS SELECT
426+
big_int % 0::BIGINT UNSIGNED AS big_un_int
427+
FROM numeric_un_tbl"""
428+
self.expected_error = (
429+
"attempt to calculate the remainder with a divisor of zero"
430+
)
431+
432+
433+
class neg_mod_un_intt(TstView):
434+
def __init__(self):
435+
# checked manually
436+
self.sql = """CREATE MATERIALIZED VIEW mod_un_intt AS SELECT
437+
intt % 0::INTEGER UNSIGNED AS un_intt
438+
FROM numeric_un_tbl"""
439+
self.expected_error = (
440+
"attempt to calculate the remainder with a divisor of zero"
441+
)

0 commit comments

Comments
 (0)