Pular para o conteúdo principal

groupBitmapAnd

Introduzido em: v20.1.0 Calcula o AND de uma coluna de bitmap e retorna sua cardinalidade. Se o combinador de sufixo -State for adicionado, ele retornará um objeto bitmap. Sintaxe
groupBitmapAnd(expr)
groupBitmapAndState(expr)
Argumentos Valor retornado Retorna uma contagem do tipo UInt64 ou um objeto bitmap ao usar -State. UInt64 Exemplos Exemplo de uso
Query
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%');
Response
┌─groupBitmapAnd(z)─┐
│               3   │
└───────────────────┘
Usando o combinador -State
Query
SELECT arraySort(bitmapToArray(groupBitmapAndState(z))) FROM bitmap_column_expr_test2 WHERE like(tag_id, 'tag%');
Response
┌─arraySort(bitmapToArray(groupBitmapAndState(z)))─┐
│ [6,8,10]                                         │
└──────────────────────────────────────────────────┘
Última modificação em 10 de junho de 2026