Bitmap Functions
This page provides a comprehensive overview of Bitmap functions in Databend, organized by functionality for easy reference.
Bitmap Operations
Bitmap Information
| Function | Description | Example |
|---|---|---|
| BITMAP_COUNT | Returns the number of elements in a bitmap | BITMAP_COUNT(BUILD_BITMAP([1,2,3])) → 3 |
| BITMAP_CONTAINS | Checks if a bitmap contains a specific element | BITMAP_CONTAINS(BUILD_BITMAP([1,2,3]), 2) → true |
| BITMAP_HAS_ANY | Checks if a bitmap contains any element from another bitmap | BITMAP_HAS_ANY(BUILD_BITMAP([1,2,3]), BUILD_BITMAP([3,4])) → true |
| BITMAP_HAS_ALL | Checks if a bitmap contains all elements from another bitmap | BITMAP_HAS_ALL(BUILD_BITMAP([1,2,3]), BUILD_BITMAP([2,3])) → true |
| BITMAP_MIN | Returns the minimum element in a bitmap | BITMAP_MIN(BUILD_BITMAP([1,2,3])) → 1 |
| BITMAP_MAX | Returns the maximum element in a bitmap | BITMAP_MAX(BUILD_BITMAP([1,2,3])) → 3 |
| BITMAP_CARDINALITY | Returns the number of elements in a bitmap | BITMAP_CARDINALITY(BUILD_BITMAP([1,2,3])) → 3 |
Bitmap Count Operations
| Function | Description | Example |
|---|---|---|
| BITMAP_AND_COUNT | Returns the count of elements in the bitwise AND of two bitmaps | BITMAP_AND_COUNT(BUILD_BITMAP([1,2,3]), BUILD_BITMAP([2,3,4])) → 2 |
| BITMAP_OR_COUNT | Returns the count of elements in the bitwise OR of two bitmaps | BITMAP_OR_COUNT(BUILD_BITMAP([1,2]), BUILD_BITMAP([2,3])) → 3 |
| BITMAP_XOR_COUNT | Returns the count of elements in the bitwise XOR of two bitmaps | BITMAP_XOR_COUNT(BUILD_BITMAP([1,2,3]), BUILD_BITMAP([2,3,4])) → 2 |
| BITMAP_NOT_COUNT | Returns the count of elements in the bitwise NOT of a bitmap | BITMAP_NOT_COUNT(BUILD_BITMAP([1,2,3]), 5) → 2 |
| INTERSECT_COUNT | Returns the count of elements in the intersection of multiple bitmaps | INTERSECT_COUNT([BUILD_BITMAP([1,2,3]), BUILD_BITMAP([2,3,4])]) → 2 |
