From f1e4af5a2223c07f9498684c0c2973a87748888c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=8C=E6=B6=9B?= Date: Sun, 26 Sep 2021 14:43:37 +0800 Subject: [PATCH] use force_index_by_date and force_primary_key for tests --- .../0_stateless/02030_tuple_filter.reference | 2 -- .../queries/0_stateless/02030_tuple_filter.sh | 30 ------------------- .../0_stateless/02030_tuple_filter.sql | 14 +++++++++ 3 files changed, 14 insertions(+), 32 deletions(-) delete mode 100755 tests/queries/0_stateless/02030_tuple_filter.sh create mode 100644 tests/queries/0_stateless/02030_tuple_filter.sql diff --git a/tests/queries/0_stateless/02030_tuple_filter.reference b/tests/queries/0_stateless/02030_tuple_filter.reference index 48849bca053..572e1a67238 100644 --- a/tests/queries/0_stateless/02030_tuple_filter.reference +++ b/tests/queries/0_stateless/02030_tuple_filter.reference @@ -1,4 +1,2 @@ 1 A 2021-01-01 1 A 2021-01-01 -3 -3 diff --git a/tests/queries/0_stateless/02030_tuple_filter.sh b/tests/queries/0_stateless/02030_tuple_filter.sh deleted file mode 100755 index 424b2f40ac5..00000000000 --- a/tests/queries/0_stateless/02030_tuple_filter.sh +++ /dev/null @@ -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}"; - diff --git a/tests/queries/0_stateless/02030_tuple_filter.sql b/tests/queries/0_stateless/02030_tuple_filter.sql new file mode 100644 index 00000000000..7e0a9be6d55 --- /dev/null +++ b/tests/queries/0_stateless/02030_tuple_filter.sql @@ -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;