2019-07-28 11:56:16 +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
|
2020-08-01 00:52:41 +00:00
|
|
|
. "$CURDIR"/mergetree_mutations.lib
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS indices_mutaions1;"
|
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS indices_mutaions2;"
|
2019-07-28 11:56:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -n --query="
|
2020-05-29 10:08:11 +00:00
|
|
|
CREATE TABLE indices_mutaions1
|
2019-07-28 11:56:16 +00:00
|
|
|
(
|
|
|
|
u64 UInt64,
|
|
|
|
i64 Int64,
|
|
|
|
i32 Int32,
|
|
|
|
INDEX idx (i64, u64 * i64) TYPE minmax GRANULARITY 1
|
2020-08-26 17:45:20 +00:00
|
|
|
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00975/indices_mutaions', 'r1')
|
2019-07-28 11:56:16 +00:00
|
|
|
PARTITION BY i32
|
|
|
|
ORDER BY u64
|
|
|
|
SETTINGS index_granularity = 2;
|
2020-05-29 10:08:11 +00:00
|
|
|
CREATE TABLE indices_mutaions2
|
2019-07-28 11:56:16 +00:00
|
|
|
(
|
|
|
|
u64 UInt64,
|
|
|
|
i64 Int64,
|
|
|
|
i32 Int32,
|
|
|
|
INDEX idx (i64, u64 * i64) TYPE minmax GRANULARITY 1
|
2020-08-26 17:45:20 +00:00
|
|
|
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00975/indices_mutaions', 'r2')
|
2019-07-28 11:56:16 +00:00
|
|
|
PARTITION BY i32
|
|
|
|
ORDER BY u64
|
|
|
|
SETTINGS index_granularity = 2;"
|
|
|
|
|
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="INSERT INTO indices_mutaions1 VALUES
|
2019-07-28 11:56:16 +00:00
|
|
|
(0, 2, 1),
|
|
|
|
(1, 1, 1),
|
|
|
|
(2, 1, 1),
|
|
|
|
(3, 1, 1),
|
|
|
|
(4, 1, 1),
|
|
|
|
(5, 2, 1),
|
|
|
|
(6, 1, 2),
|
|
|
|
(7, 1, 2),
|
|
|
|
(8, 1, 2),
|
|
|
|
(9, 1, 2)"
|
|
|
|
|
2020-07-09 14:48:46 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="SYSTEM SYNC REPLICA indices_mutaions2"
|
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2;"
|
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2 FORMAT JSON;" | grep "rows_read"
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="ALTER TABLE indices_mutaions1 CLEAR INDEX idx IN PARTITION 1;" --replication_alter_partitions_sync=2 --mutations_sync=2
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2;"
|
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2 FORMAT JSON;" | grep "rows_read"
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="ALTER TABLE indices_mutaions1 MATERIALIZE INDEX idx IN PARTITION 1;" --replication_alter_partitions_sync=2 --mutations_sync=2
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2;"
|
|
|
|
$CLICKHOUSE_CLIENT --query="SELECT count() FROM indices_mutaions2 WHERE i64 = 2 FORMAT JSON;" | grep "rows_read"
|
2019-07-28 11:56:16 +00:00
|
|
|
|
2020-05-29 10:08:11 +00:00
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE indices_mutaions1"
|
|
|
|
$CLICKHOUSE_CLIENT --query="DROP TABLE indices_mutaions2"
|