ClickHouse/tests/queries/1_stateful/00157_cache_dictionary.sql

22 lines
1.2 KiB
MySQL
Raw Normal View History

2020-08-12 13:06:46 +00:00
CREATE DATABASE IF NOT EXISTS db_dict;
DROP DICTIONARY IF EXISTS db_dict.cache_hits;
2020-08-19 01:51:59 +00:00
CREATE DICTIONARY db_dict.cache_hits
2020-08-20 14:39:30 +00:00
(WatchID UInt64, UserID UInt64, SearchPhrase String)
2020-08-19 01:51:59 +00:00
PRIMARY KEY WatchID
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'hits' PASSWORD '' DB 'test'))
LIFETIME(MIN 1 MAX 10)
LAYOUT(CACHE(SIZE_IN_CELLS 1 QUERY_WAIT_TIMEOUT_MILLISECONDS 60000));
2020-08-12 13:06:46 +00:00
2020-08-19 01:51:59 +00:00
SELECT count() FROM (SELECT WatchID, arrayDistinct(groupArray(dictGetUInt64( 'db_dict.cache_hits', 'UserID', toUInt64(WatchID)))) as arr
FROM test.hits PREWHERE WatchID % 5 == 0 GROUP BY WatchID order by length(arr) desc) WHERE arr = [0];
2020-08-12 13:06:46 +00:00
2020-08-19 01:51:59 +00:00
SELECT count() FROM (SELECT WatchID, arrayDistinct(groupArray(dictGetUInt64( 'db_dict.cache_hits', 'UserID', toUInt64(WatchID)))) as arr
FROM test.hits PREWHERE WatchID % 7 == 0 GROUP BY WatchID order by length(arr) desc) WHERE arr = [0];
2020-08-12 13:06:46 +00:00
2020-08-19 01:51:59 +00:00
SELECT count() FROM (SELECT WatchID, arrayDistinct(groupArray(dictGetUInt64( 'db_dict.cache_hits', 'UserID', toUInt64(WatchID)))) as arr
FROM test.hits PREWHERE WatchID % 13 == 0 GROUP BY WatchID order by length(arr) desc) WHERE arr = [0];
2020-08-12 13:06:46 +00:00
DROP DICTIONARY IF EXISTS db_dict.cache_hits;
DROP DATABASE IF EXISTS db_dict;