数据仓库服务 GAUSSDB(DWS)-Roaring Bitmap聚合函数:rb_and_agg(roaringbitmap)

时间:2024-09-24 15:54:36

rb_and_agg(roaringbitmap)

描述:将分组内的roaringbitmap数据按照交的操作聚合成一个roaringbitmap集合。

示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
CREATE TABLE r1(a int ,b roaringbitmap);
INSERT INTO r1 SELECT a, rb_build_agg(b) FROM t1 GROUP BY a;
INSERT INTO t1 SELECT generate_series(1,10),generate_series(1,20,4);
INSERT INTO r1 SELECT a, rb_build_agg(b) FROM t1 GROUP BY a;
SELECT a, rb_to_array(rb_and_agg(b)) FROM r1 GROUP BY a ORDER BY a;
 a  | rb_to_array
----+-------------
 1  | {1}
 2  | {3}
 3  | {5}
 4  | {7}
 5  | {9}
 6  | {11}
 7  | {13}
 8  | {15}
 9  | {17}
10  | {19}
(10 rows)
support.huaweicloud.com/sqlreference-910-dws/dws_06_0324.html