2021-09-28 18:42:41 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CURDIR " /../shell_config.sh
2021-10-04 21:13:18 +00:00
declare -a engines = ( "MergeTree order by n" " ReplicatedMergeTree('/test/01162/ $CLICKHOUSE_TEST_ZOOKEEPER_PREFIX ', '1') order by n " "Memory" "Join(ALL, FULL, n)" )
$CLICKHOUSE_CLIENT -q "CREATE OR REPLACE VIEW t1 AS SELECT number * 10 AS id, number * 100 AS value FROM numbers(20)"
2021-09-28 18:42:41 +00:00
for engine in " ${ engines [@] } "
do
$CLICKHOUSE_CLIENT -q "drop table if exists t"
2022-03-14 10:02:56 +00:00
$CLICKHOUSE_CLIENT -q " create table t (n int) engine= $engine " 2>& 1| grep -Ev "Removing leftovers from table|removed by another replica"
2021-10-04 21:13:18 +00:00
$CLICKHOUSE_CLIENT -q "select engine from system.tables where database=currentDatabase() and name='t'"
2021-09-28 18:42:41 +00:00
$CLICKHOUSE_CLIENT -q "insert into t values (1)"
$CLICKHOUSE_CLIENT -q "insert into t values (2)"
$CLICKHOUSE_CLIENT -q "select * from t order by n"
2021-10-07 12:04:54 +00:00
$CLICKHOUSE_CLIENT --allow_nondeterministic_mutations= 1 --mutations_sync= 1 -q " alter table t
delete where n global in ( select * from ( select * from t where n global in ( 1::Int32) ) ) "
2021-09-29 10:37:44 +00:00
$CLICKHOUSE_CLIENT -q "select * from t order by n"
2021-10-07 12:04:54 +00:00
$CLICKHOUSE_CLIENT --allow_nondeterministic_mutations= 1 --mutations_sync= 1 -q " alter table t
delete where n global in ( select t1.n from t as t1 full join t as t2 on t1.n= t2.n where t1.n global in ( select 2::Int32) ) "
2021-09-28 18:42:41 +00:00
$CLICKHOUSE_CLIENT -q "select count() from t"
$CLICKHOUSE_CLIENT -q "drop table t"
2021-10-04 21:13:18 +00:00
$CLICKHOUSE_CLIENT -q "drop table if exists test"
2022-03-14 10:02:56 +00:00
$CLICKHOUSE_CLIENT -q " CREATE TABLE test ENGINE= $engine AS SELECT number + 100 AS n, 0 AS test FROM numbers(50) " 2>& 1| grep -Ev "Removing leftovers from table|removed by another replica"
2021-10-04 21:13:18 +00:00
$CLICKHOUSE_CLIENT -q "select count(), sum(n), sum(test) from test"
2021-10-07 12:04:54 +00:00
if [ [ $engine = = *"ReplicatedMergeTree" * ] ] ; then
2022-06-23 12:11:16 +00:00
$CLICKHOUSE_CLIENT -q " ALTER TABLE test
2022-06-23 07:59:13 +00:00
UPDATE test = ( SELECT groupArray( id) FROM t1 GROUP BY 'dummy' ) [ n - 99] WHERE 1" 2>&1| grep -Fa " DB::Exception: " | grep -Fv " statement with subquery may be nondeterministic"
$CLICKHOUSE_CLIENT --allow_nondeterministic_mutations= 1 --mutations_sync= 1 -q " ALTER TABLE test
2022-06-19 22:45:22 +00:00
UPDATE test = ( SELECT groupArray( id) FROM t1) [ n - 99] WHERE 1"
2021-10-07 12:04:54 +00:00
elif [ [ $engine = = *"Join" * ] ] ; then
2022-06-23 07:59:13 +00:00
$CLICKHOUSE_CLIENT -q " ALTER TABLE test
2022-06-19 22:45:22 +00:00
UPDATE test = ( SELECT groupArray( id) FROM t1) [ n - 99] WHERE 1" 2>&1| grep -Fa " DB::Exception: " | grep -Fv " Table engine Join supports only DELETE mutations"
2021-10-07 12:04:54 +00:00
else
2022-06-23 07:59:13 +00:00
$CLICKHOUSE_CLIENT --mutations_sync= 1 -q " ALTER TABLE test
2022-06-19 22:45:22 +00:00
UPDATE test = ( SELECT groupArray( id) FROM t1) [ n - 99] WHERE 1"
2021-10-07 12:04:54 +00:00
fi
2021-10-04 21:13:18 +00:00
$CLICKHOUSE_CLIENT -q "select count(), sum(n), sum(test) from test"
$CLICKHOUSE_CLIENT -q "drop table test"
2021-09-28 18:42:41 +00:00
done