2021-09-12 12:35:27 +00:00
-- Tags: no-tsan, no-parallel
2024-02-13 07:33:09 +00:00
-- Suppress "ReadWriteBufferFromHTTP: HTTP request to `{}` failed at try 1/10 with bytes read: 311149/378695. Error: DB::HTTPException: Received error from remote server {}. (Current backoff wait is 100/10000 ms)" errors
SET send_logs_level = ' error ' ;
2022-05-18 10:12:41 +00:00
DROP TABLE IF EXISTS test . hits_1m ;
2024-01-14 06:50:35 +00:00
CREATE TABLE test . hits_1m AS test . hits
ENGINE = MergeTree
PARTITION BY toYYYYMM ( EventDate )
ORDER BY ( CounterID , EventDate , intHash32 ( UserID ) )
SAMPLE BY intHash32 ( UserID )
SETTINGS storage_policy = ' default ' ;
2022-05-18 10:12:41 +00:00
INSERT INTO test . hits_1m SELECT * FROM test . hits LIMIT 1000000 ;
2020-08-12 13:06:46 +00:00
CREATE DATABASE IF NOT EXISTS db_dict ;
DROP DICTIONARY IF EXISTS db_dict . cache_hits ;
2020-12-04 02:15:44 +00:00
CREATE DICTIONARY db_dict . cache_hits
( WatchID UInt64 , UserID UInt64 , SearchPhrase String )
PRIMARY KEY WatchID
2022-05-18 10:12:41 +00:00
SOURCE ( CLICKHOUSE ( HOST ' localhost ' PORT tcpPort ( ) USER ' default ' TABLE ' hits_1m ' PASSWORD ' ' DB ' test ' ) )
2020-12-04 02:15:44 +00:00
LIFETIME ( MIN 1 MAX 10 )
2020-08-19 01:51:59 +00:00
LAYOUT ( CACHE ( SIZE_IN_CELLS 1 QUERY_WAIT_TIMEOUT_MILLISECONDS 60000 ) ) ;
2020-08-12 13:06:46 +00:00
2020-12-04 02:15:44 +00:00
SELECT count ( ) FROM ( SELECT WatchID , arrayDistinct ( groupArray ( dictGetUInt64 ( ' db_dict.cache_hits ' , ' UserID ' , toUInt64 ( WatchID ) ) ) ) as arr
2022-05-18 10:12:41 +00:00
FROM test . hits_1m PREWHERE WatchID % 5 = = 0 GROUP BY WatchID order by length ( arr ) desc ) WHERE arr = [ 0 ] ;
2020-08-12 13:06:46 +00:00
2020-12-04 02:15:44 +00:00
SELECT count ( ) FROM ( SELECT WatchID , arrayDistinct ( groupArray ( dictGetUInt64 ( ' db_dict.cache_hits ' , ' UserID ' , toUInt64 ( WatchID ) ) ) ) as arr
2022-05-18 10:12:41 +00:00
FROM test . hits_1m PREWHERE WatchID % 7 = = 0 GROUP BY WatchID order by length ( arr ) desc ) WHERE arr = [ 0 ] ;
2020-08-12 13:06:46 +00:00
2020-12-04 02:15:44 +00:00
SELECT count ( ) FROM ( SELECT WatchID , arrayDistinct ( groupArray ( dictGetUInt64 ( ' db_dict.cache_hits ' , ' UserID ' , toUInt64 ( WatchID ) ) ) ) as arr
2022-05-18 10:12:41 +00:00
FROM test . hits_1m 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 ;
2022-05-18 10:12:41 +00:00
DROP TABLE IF EXISTS hits_1m ;