INTERSECT_COUNT
Descriptionβ
Calculate the intersection of two or more bitmaps Usage: intersect_count(bitmap_column_to_count, filter_column, filter_values ...) Example: intersect_count(user_id, event, 'A', 'B', 'C'), meaning find the intersect count of user_id in all A/B/C 3 bitmaps Calculate the intersection count of elements in bitmap_column that match column_to_filter within filter_values, i.e., bitmap intersection count.
Syntaxβ
INTERSECT_COUNT(<bitmap_column>, <column_to_filter>, <filter_values> [, ...])
Parametersβ
Parameter | Description |
---|---|
<bitmap_column> | The input bitmap parameter column |
<column_to_filter> | The dimension column used for filtering |
<filter_values> | The different values used to filter the dimension column |
Return Valueβ
Return the number of elements in the intersection of the given bitmaps.
Exampleβ
select dt,bitmap_to_string(user_id) from pv_bitmap;
+------+---------------------------+
| dt | bitmap_to_string(user_id) |
+------+---------------------------+
| 1 | 1,2 |
| 2 | 2,3 |
| 4 | 1,2,3,4,5 |
| 3 | 1,2,3 |
+------+---------------------------+
select intersect_count(user_id,dt,3,4) from pv_bitmap;
+------------------------------------+
| intersect_count(user_id, dt, 3, 4) |
+------------------------------------+
| 3 |
+------------------------------------+