forked from citusdata/postgresql-hll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_agg.sql
75 lines (47 loc) · 2.01 KB
/
add_agg.sql
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
69
70
71
72
73
74
75
-- ----------------------------------------------------------------
-- Regression tests for add aggregate hashval function.
-- ----------------------------------------------------------------
SELECT hll_set_output_version(1);
DROP TABLE IF EXISTS test_khvengxf;
CREATE TABLE test_khvengxf (
val integer
);
insert into test_khvengxf(val) values (1), (2), (3);
-- Check default and explicit signatures.
select hll_print(hll_add_agg(hll_hash_integer(val)))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, -1))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 0))
from test_khvengxf;
-- Check range checking.
select hll_print(hll_add_agg(hll_hash_integer(val), -1))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 32))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, -1))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 8))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, -2))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 8589934592))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, -1))
from test_khvengxf;
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 2))
from test_khvengxf;
-- Check that we return hll_empty on null input.
select hll_print(hll_add_agg(NULL));
select hll_print(hll_add_agg(NULL, 10));
select hll_print(hll_add_agg(NULL, 10, 4));
select hll_print(hll_add_agg(NULL, 10, 4, 512));
select hll_print(hll_add_agg(NULL, 10, 4, -1));
select hll_print(hll_add_agg(NULL, 10, 4, 512, 0));
DROP TABLE test_khvengxf;