Skip to main content

BITMAP_NOT

Description​

Computes the difference between the first Bitmap and the second Bitmap, and returns the result as a new Bitmap.

Syntax​

BITMAP_NOT(<bitmap1>, <bitmap2>)

Parameters​

ParameterDescription
<bitmap1>The first Bitmap
<bitmap2>The second Bitmap

Return Value​

A Bitmap representing the elements in <bitmap1> that are not in <bitmap2>.

  • If the parameter has a NULL value, it returns NULL

Examples​

To compute the difference between two Bitmaps:

select bitmap_to_string(bitmap_not(bitmap_from_string('2,3'), bitmap_from_string('1,2,3,4'))) as res;

The result will be an empty Bitmap, as all elements in <bitmap1> are also in <bitmap2>:

+------+
| res |
+------+
| |
+------+

To compute the difference where <bitmap1> has elements not present in <bitmap2>:

select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), bitmap_from_string('1,2,3,4'))) as res;

The result will be a Bitmap containing the element 5:

+------+
| res |
+------+
| 5 |
+------+
select bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'), NULL)) as res;
+------+
| res |
+------+
| NULL |
+------+