Simplify tests for mutations

This commit is contained in:
Alexey Milovidov 2020-09-04 02:28:44 +03:00
parent 40ad23245c
commit 0e53cd26a0
9 changed files with 25 additions and 72 deletions

View File

@ -3,8 +3,6 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS alter_update"
${CLICKHOUSE_CLIENT} --query="CREATE TABLE alter_update \
@ -26,8 +24,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \
('2000-01-01', 123, 'abc', 1), \
('2000-01-01', 234, 'cde', 2)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update UPDATE value1 = 'aaa', value2 = value2 + 100 WHERE key < 200"
wait_for_mutation "alter_update" "mutation_2.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update UPDATE value1 = 'aaa', value2 = value2 + 100 WHERE key < 200" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key"
@ -40,8 +37,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES ('2000-01-01', 123
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \
UPDATE value2 = (value2 + 1) / 2 WHERE 1, \
UPDATE value2 = value2 + 1 WHERE 1"
wait_for_mutation "alter_update" "mutation_4.txt"
UPDATE value2 = value2 + 1 WHERE 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key"
@ -59,8 +55,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \
DELETE WHERE key IN (SELECT toUInt32(arrayJoin([121, 122, 123]))), \
UPDATE value1 = concat(value1, 'ccc') WHERE value2 IN (20, 30), \
UPDATE value1 = 'iii' WHERE value2 IN (SELECT toUInt64(40))"
wait_for_mutation "alter_update" "mutation_6.txt"
UPDATE value1 = 'iii' WHERE value2 IN (SELECT toUInt64(40))" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key"
@ -75,8 +70,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \
UPDATE value2 = value2 + 10 WHERE 1, \
DELETE WHERE value2 = 20"
wait_for_mutation "alter_update" "mutation_8.txt"
DELETE WHERE value2 = 20" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key"
@ -96,8 +90,7 @@ ${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \
UPDATE value2 = value2 + 10 WHERE value2 <= 10, \
DELETE WHERE length(value1) + value2 = 23, \
DELETE WHERE materialized_value = 'materialized_37', \
UPDATE value1 = concat(value1, '_', materialized_value) WHERE key = 456"
wait_for_mutation "alter_update" "mutation_10.txt"
UPDATE value1 = concat(value1, '_', materialized_value) WHERE key = 456" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT * FROM alter_update ORDER BY key"
@ -123,8 +116,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO alter_update VALUES \
('2000-01-01', 456, 'ijk', 40)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE alter_update \
UPDATE value2 = value2 + 7 WHERE value2 <= 20"
wait_for_mutation "alter_update" "mutation_12.txt"
UPDATE value2 = value2 + 7 WHERE value2 <= 20" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT value2, materialized_value FROM alter_update ORDER BY key"

View File

@ -3,9 +3,7 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
${CLICKHOUSE_CLIENT} --multiquery << EOF
${CLICKHOUSE_CLIENT} --multiquery --mutations_sync=1 << EOF
DROP TABLE IF EXISTS mutations;
DROP TABLE IF EXISTS for_subquery;
@ -19,8 +17,6 @@ ALTER TABLE mutations UPDATE y = y + 1 WHERE x IN for_subquery;
ALTER TABLE mutations UPDATE y = y + 1 WHERE x IN (SELECT x FROM for_subquery);
EOF
wait_for_mutation "mutations" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM mutations"
${CLICKHOUSE_CLIENT} --query="DROP TABLE mutations"

View File

@ -3,17 +3,13 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS ordinary_00682"
${CLICKHOUSE_CLIENT} --query="CREATE TABLE ordinary_00682(k UInt32) ENGINE MergeTree ORDER BY k"
${CLICKHOUSE_CLIENT} --query="INSERT INTO ordinary_00682(k) VALUES (1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO ordinary_00682(k) VALUES (1)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE ordinary_00682 DELETE WHERE k = 1"
wait_for_mutation "ordinary_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE ordinary_00682 DELETE WHERE k = 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE ordinary_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM ordinary_00682"
@ -32,8 +28,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE vertical_00682(k UInt32, v UInt32) EN
${CLICKHOUSE_CLIENT} --query="INSERT INTO vertical_00682(k, v) VALUES (1, 1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO vertical_00682(k, v) VALUES (2, 2)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE vertical_00682 DELETE WHERE k = 1"
wait_for_mutation "vertical_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE vertical_00682 DELETE WHERE k = 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE vertical_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM vertical_00682"
@ -47,8 +42,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE summing_00682(k UInt32, v UInt32) ENG
${CLICKHOUSE_CLIENT} --query="INSERT INTO summing_00682(k, v) VALUES (1, 1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO summing_00682(k, v) VALUES (1, 2)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE summing_00682 DELETE WHERE k = 1"
wait_for_mutation "summing_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE summing_00682 DELETE WHERE k = 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE summing_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM summing_00682"
@ -62,8 +56,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE aggregating_00682(k UInt32, v Aggrega
${CLICKHOUSE_CLIENT} --query="INSERT INTO aggregating_00682(k) VALUES (1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO aggregating_00682(k) VALUES (1)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE aggregating_00682 DELETE WHERE k = 1"
wait_for_mutation "aggregating_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE aggregating_00682 DELETE WHERE k = 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE aggregating_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM aggregating_00682"
@ -77,8 +70,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE replacing_00682(k UInt32, v String) E
${CLICKHOUSE_CLIENT} --query="INSERT INTO replacing_00682(k, v) VALUES (1, 'a')"
${CLICKHOUSE_CLIENT} --query="INSERT INTO replacing_00682(k, v) VALUES (1, 'b')"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE replacing_00682 DELETE WHERE k = 1"
wait_for_mutation "replacing_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE replacing_00682 DELETE WHERE k = 1" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE replacing_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM replacing_00682"
@ -92,8 +84,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE collapsing_00682(k UInt32, v String,
${CLICKHOUSE_CLIENT} --query="INSERT INTO collapsing_00682(k, v, s) VALUES (1, 'a', 1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO collapsing_00682(k, v, s) VALUES (2, 'b', 1)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE collapsing_00682 DELETE WHERE k IN (1, 2)"
wait_for_mutation "collapsing_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE collapsing_00682 DELETE WHERE k IN (1, 2)" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE collapsing_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM collapsing_00682"
@ -107,8 +98,7 @@ ${CLICKHOUSE_CLIENT} --query="CREATE TABLE versioned_collapsing_00682(k UInt32,
${CLICKHOUSE_CLIENT} --query="INSERT INTO versioned_collapsing_00682(k, val, ver, s) VALUES (1, 'a', 0, 1)"
${CLICKHOUSE_CLIENT} --query="INSERT INTO versioned_collapsing_00682(k, val, ver, s) VALUES (2, 'b', 0, 1)"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE versioned_collapsing_00682 DELETE WHERE k IN (1, 2)"
wait_for_mutation "versioned_collapsing_00682" "mutation_3.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE versioned_collapsing_00682 DELETE WHERE k IN (1, 2)" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="OPTIMIZE TABLE versioned_collapsing_00682 PARTITION tuple() FINAL"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM versioned_collapsing_00682"

View File

@ -4,8 +4,6 @@ set -e
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
${CLICKHOUSE_CLIENT} --multiquery --query="
DROP TABLE IF EXISTS view_00699;
@ -18,18 +16,14 @@ INSERT INTO null_00699 SELECT * FROM numbers(100);
SELECT count(), min(x), max(x) FROM null_00699;
SELECT count(), min(x), max(x) FROM view_00699;
ALTER TABLE null_00699 DELETE WHERE x % 2 = 0;"
wait_for_mutation null_00699 mutation_2.txt
ALTER TABLE null_00699 DELETE WHERE x % 2 = 0;" --mutations_sync=1
${CLICKHOUSE_CLIENT} --multiquery --query="
SELECT count(), min(x), max(x) FROM null_00699;
SELECT count(), min(x), max(x) FROM view_00699;
ALTER TABLE view_00699 DELETE WHERE x % 2 = 0;
"
wait_for_mutation .inner.view_00699 mutation_2.txt
" --mutations_sync=1
${CLICKHOUSE_CLIENT} --multiquery --query="
SELECT count(), min(x), max(x) FROM null_00699;
@ -37,10 +31,7 @@ SELECT count(), min(x), max(x) FROM view_00699;
ALTER TABLE null_00699 DELETE WHERE x % 2 = 1;
ALTER TABLE view_00699 DELETE WHERE x % 2 = 1;
"
wait_for_mutation null_00699 mutation_3.txt
wait_for_mutation .inner.view_00699 mutation_3.txt
" --mutations_sync=1
${CLICKHOUSE_CLIENT} --multiquery --query="
SELECT count(), min(x), max(x) FROM null_00699;

View File

@ -2,11 +2,9 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS minmax_idx;"
$CLICKHOUSE_CLIENT -n --query="
CREATE TABLE minmax_idx
(
@ -18,7 +16,6 @@ CREATE TABLE minmax_idx
ORDER BY u64
SETTINGS index_granularity = 2;"
$CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES
(0, 1, 1),
(1, 1, 2),
@ -34,8 +31,7 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 1;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 5;"
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx UPDATE i64 = 5 WHERE i64 = 1;"
wait_for_mutation "minmax_idx" "mutation_2.txt" "$CLICKHOUSE_DATABASE"
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx UPDATE i64 = 5 WHERE i64 = 1;" --mutations_sync=1
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 1;"
$CLICKHOUSE_CLIENT --query="SELECT count() FROM minmax_idx WHERE i64 = 5;"

View File

@ -2,7 +2,6 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS minmax_idx;"
@ -35,16 +34,12 @@ $CLICKHOUSE_CLIENT --query="INSERT INTO minmax_idx VALUES
$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
# First two numbers are for inserted blocks in two partitions
# And this will be mutation number 3:
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx CLEAR INDEX idx IN PARTITION 1;" --replication_alter_partitions_sync=2
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx CLEAR INDEX idx IN PARTITION 1;" --mutations_sync=1
$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
# And this will be mutation number 4:
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;"
wait_for_mutation "minmax_idx" "mutation_4.txt" "$CLICKHOUSE_DATABASE"
$CLICKHOUSE_CLIENT --query="ALTER TABLE minmax_idx MATERIALIZE INDEX idx IN PARTITION 1;" --mutations_sync=1
$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

View File

@ -3,8 +3,6 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
${CLICKHOUSE_CLIENT} --query="DROP TABLE IF EXISTS json_test"
@ -14,9 +12,7 @@ ${CLICKHOUSE_CLIENT} --query="INSERT INTO json_test VALUES (1, '{\"date\": \"201
${CLICKHOUSE_CLIENT} --query="SELECT COUNT() FROM json_test"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE json_test DELETE WHERE JSONExtractString(metadata, 'date') = '2018-01-01'"
wait_for_mutation "json_test" "mutation_2.txt"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE json_test DELETE WHERE JSONExtractString(metadata, 'date') = '2018-01-01'" --mutations_sync=1
${CLICKHOUSE_CLIENT} --query="SELECT COUNT() FROM json_test"

View File

@ -1,3 +1,3 @@
Waiting for mutation to finish
Waited for mutation to finish
still alive
100

View File

@ -2,7 +2,6 @@
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
. "$CURDIR"/mergetree_mutations.lib
# that test is failing on versions <= 19.11.12
@ -11,11 +10,9 @@ ${CLICKHOUSE_CLIENT} --multiquery --query="
create table lc_empty_part_bug (id UInt64, s String) Engine=MergeTree ORDER BY id;
insert into lc_empty_part_bug select number as id, toString(rand()) from numbers(100);
alter table lc_empty_part_bug delete where id < 100;
"
" --mutations_sync=1
wait_for_mutation 'lc_empty_part_bug' 'mutation_2.txt'
echo 'Waiting for mutation to finish'
echo 'Waited for mutation to finish'
${CLICKHOUSE_CLIENT} --multiquery --query="
alter table lc_empty_part_bug modify column s LowCardinality(String);
@ -23,4 +20,4 @@ ${CLICKHOUSE_CLIENT} --multiquery --query="
insert into lc_empty_part_bug select number+100 as id, toString(rand()) from numbers(100);
SELECT count() FROM lc_empty_part_bug WHERE not ignore(*);
DROP TABLE lc_empty_part_bug;
"
" --mutations_sync=1