Skip to main content

BITMAP-UNION-INT

Description

Counts the number of distinct values in columns of type TINYINT, SMALLINT and INT. The return value is the same as COUNT(DISTINCT expr)

Syntax

BITMAP_UNION_INT(<expr>)

Parameters

ParameterDescription
<expr>Supports columns or column expressions of type TINYINT, SMALLINT and INT

Return Value

Returns the number of distinct values in a column.

Example

-- setup
create table pv_bitmap(dt int, page int, user_id bitmap bitmap_union) aggregate key(dt,page) distributed by hash(dt) buckets 1 properties ("replication_num"="1");
insert into pv_bitmap values (1,100,bitmap_from_string('100,200,300')),(1,300,bitmap_from_string('300')),(2,200,bitmap_from_string('300'));
select dt,page,bitmap_to_string(user_id) from pv_bitmap;
+------+------+---------------------------+
| dt | page | bitmap_to_string(user_id) |
+------+------+---------------------------+
| 1 | 100 | 100,200,300 |
| 1 | 300 | 300 |
| 2 | 200 | 300 |
+------+------+---------------------------+
select bitmap_union_int(dt) from pv_bitmap;
+----------------------+
| bitmap_union_int(dt) |
+----------------------+
| 2 |
+----------------------+