2019-07-12 13:42:49 +00:00
#!/usr/bin/env bash
CUR_DIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:56:32 +00:00
. " $CUR_DIR " /../shell_config.sh
2019-07-12 13:42:49 +00:00
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE IF EXISTS test_optimize_exception"
2020-05-18 09:24:48 +00:00
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE IF EXISTS test_optimize_exception_replicated"
2019-07-12 13:42:49 +00:00
${ CLICKHOUSE_CLIENT } --query= "CREATE TABLE test_optimize_exception (date Date) ENGINE=MergeTree() PARTITION BY toYYYYMM(date) ORDER BY date"
2021-03-15 04:51:28 +00:00
${ CLICKHOUSE_CLIENT } --query= " CREATE TABLE test_optimize_exception_replicated (date Date) ENGINE=ReplicatedMergeTree('/clickhouse/tables/ $CLICKHOUSE_TEST_ZOOKEEPER_PREFIX /optimize', 'r1') PARTITION BY toYYYYMM(date) ORDER BY date "
2019-07-12 13:42:49 +00:00
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test_optimize_exception VALUES (toDate('2017-09-09')), (toDate('2017-09-10'))"
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test_optimize_exception VALUES (toDate('2017-09-09')), (toDate('2017-09-10'))"
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test_optimize_exception_replicated VALUES (toDate('2017-09-09')), (toDate('2017-09-10'))"
${ CLICKHOUSE_CLIENT } --query= "INSERT INTO test_optimize_exception_replicated VALUES (toDate('2017-09-09')), (toDate('2017-09-10'))"
${ CLICKHOUSE_CLIENT } --optimize_throw_if_noop 1 --query= "OPTIMIZE TABLE test_optimize_exception PARTITION 201709 FINAL"
${ CLICKHOUSE_CLIENT } --optimize_throw_if_noop 1 --query= "OPTIMIZE TABLE test_optimize_exception_replicated PARTITION 201709 FINAL"
2020-08-01 13:25:59 +00:00
echo " $( ${ CLICKHOUSE_CLIENT } --optimize_throw_if_noop 1 --server_logs_file= /dev/null --query= "OPTIMIZE TABLE test_optimize_exception PARTITION 201710" 2>& 1) " \
2019-07-12 13:42:49 +00:00
| grep -c 'Code: 388. DB::Exception: .* DB::Exception: .* Cannot select parts for optimization'
2020-08-01 13:25:59 +00:00
echo " $( ${ CLICKHOUSE_CLIENT } --optimize_throw_if_noop 1 --server_logs_file= /dev/null --query= "OPTIMIZE TABLE test_optimize_exception_replicated PARTITION 201710" 2>& 1) " \
2019-07-12 13:42:49 +00:00
| grep -c 'Code: 388. DB::Exception: .* DB::Exception:.* Cannot select parts for optimization'
2020-03-20 00:07:52 +00:00
2020-08-26 17:45:20 +00:00
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE test_optimize_exception"
${ CLICKHOUSE_CLIENT } --query= "DROP TABLE test_optimize_exception_replicated"