groupBitmapAnd
groupBitmapAnd
비트맵 컬럼의 AND를 계산하고 그 카디널리티를 반환하는 집계 함수예요. -State 컴비네이터 접미사를 붙이면 비트맵 객체를 반환합니다.
출처: 문서
본문
도입 버전: v20.1.0
비트맵 컬럼의 AND를 계산하고 그 카디널리티를 반환합니다. -State 컴비네이터 접미사를 붙이면 비트맵 객체를 반환합니다.
구문 (Syntax)
groupBitmapAnd(expr)
groupBitmapAndState(expr)
인자 (Arguments)
expr—AggregateFunction(groupBitmap, UInt*)타입을 결과로 내는 표현식.AggregateFunction(groupBitmap, UInt*)
반환 값
UInt64 타입의 개수를 반환하거나, -State를 사용할 때는 비트맵 객체를 반환합니다. UInt64
예제
사용 예제
CREATE TABLE bitmap_column_expr_test2
(
tag_id String,
z AggregateFunction(groupBitmap, UInt32)
)
ENGINE = MergeTree
ORDER BY tag_id;
INSERT INTO bitmap_column_expr_test2 VALUES ('tag1', bitmapBuild(cast([1,2,3,4,5,6,7,8,9,10] AS Array(UInt32))));
INSERT INTO bitmap_column_expr_test2 VALUES ('tag2', bitmapBuild(cast([6,7,8,9,10,11,12,13,14,15] AS Array(UInt32))));
INSERT INTO bitmap_column_expr_test2 VALUES ('tag3', bitmapBuild(cast([2,4,6,8,10,12] AS Array(UInt32))));
SELECT groupBitmapAnd(z) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%');
┌─groupBitmapAnd(z)─┐
│ 3 │
└───────────────────┘
-State 컴비네이터 사용
SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%');
┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐
│ [6,8,10] │
└──────────────────────────────────────────────────┘