forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bitmap_binary
More file actions
155 lines (155 loc) · 6.33 KB
/
Copy pathtest_bitmap_binary
File metadata and controls
155 lines (155 loc) · 6.33 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
-- name: test_bitmap_binary
CREATE TABLE `t1` (
`c1` int(11) NULL COMMENT "",
`c2` bitmap BITMAP_UNION NULL COMMENT ""
) ENGINE=OLAP
AGGREGATE KEY(`c1`)
DISTRIBUTED BY HASH(`c1`) BUCKETS 1
PROPERTIES ("replication_num" = "1");
-- result:
-- !result
CREATE TABLE `t2` (`c1` int, `c2` string);
-- result:
-- !result
insert into t1 values (1, bitmap_empty());
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 00
-- !result
select c1, bitmap_count(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 0
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 values (1, to_bitmap(1));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 0101000000
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 1
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 values (1, to_bitmap(17179869184));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 030000000004000000
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 17179869184
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(1, 5));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 0A0500000001000000000000000200000000000000030000000000000004000000000000000500000000000000
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 1,2,3,4,5
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(1, 40));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 023B3000000100002700010001002700
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 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
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(1, 20));
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(17179869184, 17179869284));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1;
-- result:
1 0402000000003A3000000100000000001300100000000100020003000400050006000700080009000A000B000C000D000E000F0010001100120013001400040000003B3000000100006400010000006400
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1;
-- result:
1 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,17179869184,17179869185,17179869186,17179869187,17179869188,17179869189,17179869190,17179869191,17179869192,17179869193,17179869194,17179869195,17179869196,17179869197,17179869198,17179869199,17179869200,17179869201,17179869202,17179869203,17179869204,17179869205,17179869206,17179869207,17179869208,17179869209,17179869210,17179869211,17179869212,17179869213,17179869214,17179869215,17179869216,17179869217,17179869218,17179869219,17179869220,17179869221,17179869222,17179869223,17179869224,17179869225,17179869226,17179869227,17179869228,17179869229,17179869230,17179869231,17179869232,17179869233,17179869234,17179869235,17179869236,17179869237,17179869238,17179869239,17179869240,17179869241,17179869242,17179869243,17179869244,17179869245,17179869246,17179869247,17179869248,17179869249,17179869250,17179869251,17179869252,17179869253,17179869254,17179869255,17179869256,17179869257,17179869258,17179869259,17179869260,17179869261,17179869262,17179869263,17179869264,17179869265,17179869266,17179869267,17179869268,17179869269,17179869270,17179869271,17179869272,17179869273,17179869274,17179869275,17179869276,17179869277,17179869278,17179869279,17179869280,17179869281,17179869282,17179869283,17179869284
-- !result
truncate table t1;
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(1, 80));
-- result:
-- !result
insert into t1 select 2, bitmap_agg(generate_series) from table(generate_series(1, 200));
-- result:
-- !result
insert into t1 select 2, bitmap_agg(generate_series) from table(generate_series(900, 910));
-- result:
-- !result
select c1, hex(bitmap_to_binary(c2)) from t1 order by c1;
-- result:
1 023B3000000100004F00010001004F00
2 023B300000010000D20002000100C70084030A00
-- !result
select c1, bitmap_to_string(bitmap_from_binary(bitmap_to_binary(c2))) from t1 order by c1;
-- result:
1 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,76,77,78,79,80
2 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,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,900,901,902,903,904,905,906,907,908,909,910
-- !result
select bitmap_from_binary(to_binary("1234"));
-- result:
None
-- !result
select bitmap_from_binary(to_binary(""));
-- result:
None
-- !result
select bitmap_from_binary(null);
-- result:
None
-- !result
select bitmap_to_binary(null);
-- result:
None
-- !result
select bitmap_to_binary(bitmap_from_string("abc"));
-- result:
None
-- !result
truncate table t1;
-- result:
-- !result
truncate table t2;
-- result:
-- !result
insert into t1 select 1, bitmap_agg(generate_series) from table(generate_series(1, 80));
-- result:
-- !result
insert into t2 select c1, bitmap_to_binary(c2) from t1;
-- result:
-- !result
select c1, bitmap_to_string(bitmap_from_binary(c2)) from t2;
-- result:
1 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,76,77,78,79,80
-- !result