From 83b9677f1cf51d75114927e8fcdb2fe12ae078db Mon Sep 17 00:00:00 2001 From: Maksim Kita Date: Wed, 27 Jan 2021 20:35:50 +0300 Subject: [PATCH] Added test --- ...egate_function_group_bitmap_data.reference | 60 +++++++++++++++++++ ...1_aggregate_function_group_bitmap_data.sql | 55 +++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.reference create mode 100644 tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.sql diff --git a/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.reference b/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.reference new file mode 100644 index 00000000000..161f4a6372f --- /dev/null +++ b/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.reference @@ -0,0 +1,60 @@ +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 50 1 0 49 +1 50 51 0 1 51 diff --git a/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.sql b/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.sql new file mode 100644 index 00000000000..3f5c5c2f25b --- /dev/null +++ b/tests/queries/0_stateless/01671_aggregate_function_group_bitmap_data.sql @@ -0,0 +1,55 @@ +CREATE TABLE group_bitmap_data_test +( + `pickup_date` Date, + `city_id` UInt32, + `uid` UInt32 +) +ENGINE = Memory; + +INSERT INTO group_bitmap_data_test SELECT + '2019-01-01', + 1, + number +FROM numbers(1, 50); + +INSERT INTO group_bitmap_data_test SELECT + '2019-01-02', + 1, + number +FROM numbers(11, 60); + +INSERT INTO group_bitmap_data_test SELECT + '2019-01-03', + 2, + number +FROM numbers(1, 10); + +SELECT + bitmapCardinality(day_today) AS today_users, + bitmapCardinality(day_before) AS before_users, + bitmapCardinality(bitmapOr(day_today, day_before)) AS ll_users, + bitmapCardinality(bitmapAnd(day_today, day_before)) AS old_users, + bitmapCardinality(bitmapAndnot(day_today, day_before)) AS new_users, + bitmapCardinality(bitmapXor(day_today, day_before)) AS diff_users +FROM +( + SELECT + city_id, + groupBitmapState(uid) AS day_today + FROM group_bitmap_data_test + WHERE pickup_date = '2019-01-02' + GROUP BY + uid, + city_id +) AS js1 +ALL LEFT JOIN +( + SELECT + city_id, + groupBitmapState(uid) AS day_before + FROM group_bitmap_data_test + WHERE pickup_date = '2019-01-01' + GROUP BY city_id +) AS js2 USING (city_id); + +DROP TABLE IF EXISTS group_bitmap_data_test;