From 0a4761a8fae8e9b9b938b2286951a35e4c053fe4 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Thu, 9 May 2019 15:49:00 +0300 Subject: [PATCH] test for clear index --- .../00944_clear_index_in_partition.reference | 4 ++ .../00944_clear_index_in_partition.sh | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00944_clear_index_in_partition.reference create mode 100755 dbms/tests/queries/0_stateless/00944_clear_index_in_partition.sh diff --git a/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.reference b/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.reference new file mode 100644 index 00000000000..c3e1b8bdb9a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.reference @@ -0,0 +1,4 @@ +5 + "rows_read": 6, +5 + "rows_read": 10, diff --git a/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.sh b/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.sh new file mode 100755 index 00000000000..1d08f9facfc --- /dev/null +++ b/dbms/tests/queries/0_stateless/00944_clear_index_in_partition.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test.minmax_idx;" + + +$CLICKHOUSE_CLIENT -n --query=" +SET allow_experimental_data_skipping_indices=1; +CREATE TABLE test.minmax_idx +( + u64 UInt64, + i64 Int64, + i32 Int32, + INDEX idx (i64, u64 * i64) TYPE minmax GRANULARITY 1 +) ENGINE = MergeTree() +PARTITION BY i32 +ORDER BY u64 +SETTINGS index_granularity = 2;" + + +$CLICKHOUSE_CLIENT --query="INSERT INTO test.minmax_idx VALUES +(0, 2, 1), +(1, 1, 1), +(2, 1, 1), +(3, 1, 1), +(4, 2, 3), +(5, 2, 3), +(6, 2, 2), +(7, 2, 2), +(8, 1, 2), +(9, 1, 2)" + +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;" +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" + +$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx IN PARTITION 1;" + +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2;" +$CLICKHOUSE_CLIENT --query="SELECT count() FROM test.minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" + +$CLICKHOUSE_CLIENT --query="DROP TABLE test.minmax_idx"