mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
add bitmap state test sql
This commit is contained in:
parent
f62d4717d7
commit
f1a4330c69
@ -13,3 +13,5 @@
|
||||
2019-01-02 60 [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]
|
||||
60 50 70 40 20 30
|
||||
60 50 70 40 20 30
|
||||
2019-01-01 50
|
||||
2019-01-02 60
|
||||
|
@ -14,6 +14,7 @@ CREATE TABLE test.bitmap_test(pickup_date Date, city_id UInt32, uid UInt32)ENGIN
|
||||
INSERT INTO test.bitmap_test SELECT '2019-01-01', 1, number FROM numbers(1,50);
|
||||
INSERT INTO test.bitmap_test SELECT '2019-01-02', 1, number FROM numbers(11,60);
|
||||
|
||||
|
||||
SELECT groupBitmap( uid ) AS user_num FROM test.bitmap_test;
|
||||
|
||||
SELECT pickup_date, groupBitmap( uid ) AS user_num, bitmapToArray(groupBitmapState( uid )) AS users FROM test.bitmap_test GROUP BY pickup_date;
|
||||
@ -53,4 +54,24 @@ ALL LEFT JOIN
|
||||
USING city_id;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS test.bitmap_state_test;
|
||||
CREATE TABLE test.bitmap_state_test
|
||||
(
|
||||
pickup_date Date,
|
||||
city_id UInt32,
|
||||
uv AggregateFunction( groupBitmap, UInt32 )
|
||||
)
|
||||
ENGINE = AggregatingMergeTree( pickup_date, ( pickup_date, city_id ), 8192);
|
||||
|
||||
INSERT INTO test.bitmap_state_test SELECT
|
||||
pickup_date,
|
||||
city_id,
|
||||
groupBitmapState(uid) AS uv
|
||||
FROM test.bitmap_test
|
||||
GROUP BY pickup_date, city_id;
|
||||
|
||||
SELECT pickup_date, groupBitmapMerge(uv) AS users from test.bitmap_state_test group by pickup_date;
|
||||
|
||||
DROP TABLE IF EXISTS test.bitmap_test;
|
||||
DROP TABLE IF EXISTS test.bitmap_state_test;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user