use force_index_by_date and force_primary_key for tests

This commit is contained in:
凌涛 2021-09-26 14:43:37 +08:00 committed by vdimir
parent f660224a5f
commit f1e4af5a22
No known key found for this signature in database
GPG Key ID: 9B404D301C0CC7EB
3 changed files with 14 additions and 32 deletions

View File

@ -1,4 +1,2 @@
1 A 2021-01-01
1 A 2021-01-01
3
3

View File

@ -1,30 +0,0 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
uniq_num=$(date "+%Y%m%d%H%M%S%s")
table=tuple_filter_test_${uniq_num}
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS ${table}";
$CLICKHOUSE_CLIENT --query="CREATE TABLE ${table} (id UInt32, value String, log_date Date) Engine=MergeTree() ORDER BY id PARTITION BY log_date settings index_granularity=3;";
$CLICKHOUSE_CLIENT --query="insert into ${table} values (1, 'A','2021-01-01'),(2,'B','2021-01-01'),(3,'C','2021-01-01'),(4,'D','2021-01-02'),(5,'E','2021-01-02');";
$CLICKHOUSE_CLIENT --query="select * from ${table} where (id, value) = (1, 'A');";
$CLICKHOUSE_CLIENT --query="select * from ${table} where (log_date, value) = ('2021-01-01', 'A');";
#Make sure the quer log has been insert into query_log table
sleep 10
$CLICKHOUSE_CLIENT --query="select read_rows from system.query_log where query in ('select * from ${table} where (id, value) = (1, \'A\');', 'select * from ${table} where (log_date, value) = (\'2021-01-01\', \'A\');') and type = 2;";
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS ${table}";

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS test_tuple_filter;
CREATE TABLE test_tuple_filter (id UInt32, value String, log_date Date) Engine=MergeTree() ORDER BY id PARTITION BY log_date settings index_granularity=3;
insert into test_tuple_filter values (1, 'A','2021-01-01'),(2,'B','2021-01-01'),(3,'C','2021-01-01'),(4,'D','2021-01-02'),(5,'E','2021-01-02');
set force_primary_key=1;
SELECT * FROM test_tuple_filter WHERE (id, value) = (1, 'A');
set force_index_by_date=1;
set force_primary_key=0;
SELECT * FROM test_tuple_filter WHERE (log_date, value) = ('2021-01-01', 'A');
DROP TABLE IF EXISTS test_tuple_filter;