ClickHouse/dbms/tests/queries/0_stateless/00943_materialize_index.sh

67 lines
2.3 KiB
Bash
Raw Normal View History

2019-05-09 12:26:25 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
. $CURDIR/mergetree_mutations.lib
2019-05-09 12:26:25 +00:00
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test.minmax_idx;"
$CLICKHOUSE_CLIENT -n --query="
CREATE TABLE test.minmax_idx
(
u64 UInt64,
i64 Int64,
2019-05-09 12:30:32 +00:00
i32 Int32
2019-05-09 12:26:25 +00:00
) ENGINE = MergeTree()
2019-05-09 12:53:08 +00:00
PARTITION BY i32
2019-05-09 12:26:25 +00:00
ORDER BY u64
SETTINGS index_granularity = 2;"
$CLICKHOUSE_CLIENT --query="INSERT INTO test.minmax_idx VALUES
(0, 2, 1),
2019-05-09 12:53:08 +00:00
(1, 1, 1),
(2, 1, 1),
(3, 1, 1),
(4, 2, 2),
(5, 2, 2),
(6, 2, 2),
(7, 2, 2),
(8, 1, 2),
(9, 1, 2)"
2019-05-09 12:26:25 +00:00
$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"
2019-05-09 12:30:32 +00:00
$CLICKHOUSE_CLIENT -n --query="
SET allow_experimental_data_skipping_indices=1;
ALTER TABLE test.minmax_idx ADD INDEX idx (i64, u64 * i64) TYPE minmax GRANULARITY 1;"
2019-05-09 12:53:08 +00:00
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;"
2019-08-24 08:51:02 +00:00
wait_for_mutation "minmax_idx" "mutation_3.txt" "test"
2019-05-09 12:53:08 +00:00
$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 MATERIALIZE INDEX idx IN PARTITION 2;"
2019-08-24 08:51:02 +00:00
wait_for_mutation "minmax_idx" "mutation_4.txt" "test"
2019-05-09 12:53:08 +00:00
$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"
2019-08-04 18:28:46 +00:00
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx IN PARTITION 1;"
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx CLEAR INDEX idx IN PARTITION 2;"
2019-08-23 19:36:17 +00:00
sleep 0.5
2019-08-04 14:32:33 +00:00
$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"
2019-05-09 12:26:25 +00:00
$CLICKHOUSE_CLIENT --query="ALTER TABLE test.minmax_idx MATERIALIZE INDEX idx;"
2019-08-24 08:51:02 +00:00
wait_for_mutation "minmax_idx" "mutation_5.txt" "test"
2019-05-09 12:26:25 +00:00
$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"