Skip to main content

groupBitmap

Introduced in: v20.1.0 Creates a bitmap (bit array) from a column of unsigned integers, then returns the count of unique values (cardinality) in that bitmap. By appending the -State combinator suffix, instead of returning the count, it returns the actual bitmap object. Syntax
groupBitmap(expr)
groupBitmapState(expr)
Arguments
  • expr — Expression that results in a UInt* type. UInt*
Returned value Returns the count of type UInt64 type, or a bitmap object when using -State. UInt64 Examples Usage example
Query
CREATE TABLE t (UserID UInt32) ENGINE = Memory;
INSERT INTO t VALUES (1), (1), (2), (3);

SELECT groupBitmap(UserID) AS num FROM t;
Response
┌─num─┐
│   3 │
└─────┘
Last modified on June 8, 2026