ClickHouse/tests/queries/0_stateless/00944_clear_index_in_partition.sh

48 lines
1.4 KiB
Bash
Raw Normal View History

2019-05-09 12:49:00 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2019-05-09 12:49:00 +00:00
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS minmax_idx;"
2019-05-09 12:49:00 +00:00
$CLICKHOUSE_CLIENT -n --query="
CREATE TABLE minmax_idx
2019-05-09 12:49:00 +00:00
(
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 minmax_idx VALUES
2019-05-09 12:49:00 +00:00
(0, 2, 1),
(1, 1, 1),
(2, 1, 1),
(3, 1, 1),
2019-05-09 17:04:05 +00:00
(4, 1, 1),
(5, 2, 1),
(6, 1, 2),
(7, 1, 2),
2019-05-09 12:49:00 +00:00
(8, 1, 2),
(9, 1, 2)"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 4
2019-05-09 12:49:00 +00:00
2020-09-03 23:28:44 +00:00
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx CLEAR INDEX idx IN PARTITION 1;" --mutations_sync=1
2019-05-09 12:49:00 +00:00
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 6
2019-05-09 12:49:00 +00:00
2020-09-03 23:28:44 +00:00
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;" --mutations_sync=1
2019-05-09 17:04:05 +00:00
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 2 FORMAT JSON" | grep "rows_read" # Returns 4
2019-05-09 17:04:05 +00:00
$CLICKHOUSE_CLIENT --query="DROP TABLE minmax_idx"