BITMAP_CONSTRUCT_AGG

See: Understanding How Bitmaps Identify Distinct Values.

Syntax

BITMAP_CONSTRUCT_AGG( <bit_position> )

Parameters

bit_position

A numeric value that represents the BITMAP_BIT_POSITION of an input.

Returns

The function takes the relative position of multiple inputs in the bitmap, and returns a byte array that is a bitmap with bits set for each distinct input. The result should be grouped by BITMAP_BUCKET_OFFSET or BITMAP_BUCKET_NUMBER, so that values in different “buckets” are not merged together. For example:

SELECT BITMAP_BUCKET_OFFSET(UID) as offset, BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(UID)) as bitmap FROM T
GROUP BY BITMAP_BUCKET_OFFSET(UID)

``UID = 0, 1, 9999, 10000, -1``

OFFSET

BITMAP

0

[b'00000011, 0, ..., b'10000000]

1

[b'00000001, 0, ..., 0]

-1

[0, 0, ..., b'10000000]