diff --git a/tests/queries/0_stateless/03231_create_with_clone_as.reference b/tests/queries/0_stateless/03231_create_with_clone_as.reference index 4aed6849728..34f39fe932a 100644 --- a/tests/queries/0_stateless/03231_create_with_clone_as.reference +++ b/tests/queries/0_stateless/03231_create_with_clone_as.reference @@ -1,7 +1,5 @@ CREATE TABLE default.foo_memory\n(\n `x` Int8,\n `y` String\n)\nENGINE = Memory -1 CREATE TABLE default.foo_file\n(\n `x` Int8,\n `y` String\n)\nENGINE = File(\'TabSeparated\') -1 CREATE TABLE default.foo_merge_tree\n(\n `x` Int8,\n `y` String\n)\nENGINE = MergeTree\nPRIMARY KEY x\nORDER BY x\nSETTINGS index_granularity = 8192 1 a 2 b @@ -25,11 +23,9 @@ from clone_as_foo_replacing_merge_tree CREATE TABLE default.foo_replicated_merge_tree\n(\n `x` Int8,\n `y` String\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/default/test_foo_replicated_merge_tree\', \'r1\')\nPRIMARY KEY x\nORDER BY x\nSETTINGS index_granularity = 8192 1 a 2 b -1 s1 r1 OK 0 0 CREATE TABLE imdb_03231.foo_merge_tree\n(\n `x` Int8,\n `y` String\n)\nENGINE = MergeTree\nPRIMARY KEY x\nORDER BY x\nSETTINGS index_granularity = 8192 from imdb_03231.foo_merge_tree 1 a 2 b -1 s1 r1 OK 0 0 diff --git a/tests/queries/0_stateless/03231_create_with_clone_as.sh b/tests/queries/0_stateless/03231_create_with_clone_as.sh deleted file mode 100755 index 8e2cf30abce..00000000000 --- a/tests/queries/0_stateless/03231_create_with_clone_as.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# Tags: no-replicated-database - -CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# shellcheck source=../shell_config.sh -. "$CUR_DIR"/../shell_config.sh - -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_memory" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_memory" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_file" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_file" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_replicated_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_replicated_merge_tree" - -# CLONE AS with a table of Memory engine -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE foo_memory (x Int8, y String) ENGINE=Memory" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE foo_memory" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO foo_memory VALUES (1, 'a'), (2, 'b')" - -echo "$(${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 --server_logs_file=/dev/null -q "CREATE TABLE clone_as_foo_memory CLONE AS foo_memory" 2>&1)" \ - | grep -c 'Code: 344. DB::Exception: .* Only support CLONE AS with tables of the MergeTree family' - - -# CLONE AS with a table of File engine -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE foo_file (x Int8, y String) ENGINE=File(TabSeparated)" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE foo_file" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO foo_file VALUES (1, 'a'), (2, 'b')" - -echo "$(${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 --server_logs_file=/dev/null -q "CREATE TABLE clone_as_foo_file CLONE AS foo_file" 2>&1)" \ - | grep -c 'Code: 344. DB::Exception: .* Only support CLONE AS with tables of the MergeTree family' - -# CLONE AS with a table of MergeTree engine -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE foo_merge_tree (x Int8, y String) ENGINE=MergeTree PRIMARY KEY x" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO foo_merge_tree VALUES (1, 'a'), (2, 'b')" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_merge_tree" - -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE clone_as_foo_merge_tree CLONE AS foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE clone_as_foo_merge_tree" -echo "from foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_merge_tree" -echo "from clone_as_foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM clone_as_foo_merge_tree" - -# CLONE AS with a table of ReplacingMergeTree engine -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE foo_replacing_merge_tree (x Int8, y String) ENGINE=ReplacingMergeTree PRIMARY KEY x" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO foo_replacing_merge_tree VALUES (1, 'a'), (2, 'b')" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_replacing_merge_tree" - -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE clone_as_foo_replacing_merge_tree CLONE AS foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE clone_as_foo_replacing_merge_tree" -echo "from foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_replacing_merge_tree" -echo "from clone_as_foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM clone_as_foo_replacing_merge_tree" - -# CLONE AS with a table of ReplicatedMergeTree engine -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE foo_replicated_merge_tree (x Int8, y String) ENGINE=ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_DATABASE/test_foo_replicated_merge_tree', 'r1') PRIMARY KEY x" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE foo_replicated_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO foo_replicated_merge_tree VALUES (1, 'a'), (2, 'b')" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_replicated_merge_tree" -echo "$(${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 --server_logs_file=/dev/null -q "CREATE TABLE clone_as_foo_replicated_merge_tree CLONE AS foo_replicated_merge_tree" 2>&1)" \ - | grep -c 'Code: 344. DB::Exception: .* CREATE CLONE AS is not supported with Replicated storages. Consider using separate CREATE and INSERT queries.' - -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_memory" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_memory" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_file" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_file" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_replacing_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_replicated_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_replicated_merge_tree" - -# CLONE AS with a Replicated database -${CLICKHOUSE_CLIENT} -q "DROP DATABASE IF EXISTS imdb_03231" - -${CLICKHOUSE_CLIENT} -q "CREATE DATABASE imdb_03231 ENGINE = Replicated('/test/databases/$CLICKHOUSE_DATABASE/imdb_03231', 's1', 'r1')" - -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "CREATE TABLE imdb_03231.foo_merge_tree (x Int8, y String) ENGINE=MergeTree PRIMARY KEY x" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE imdb_03231.foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "INSERT INTO imdb_03231.foo_merge_tree VALUES (1, 'a'), (2, 'b')" -echo "from imdb_03231.foo_merge_tree" -${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM imdb_03231.foo_merge_tree" -echo "$(${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 --server_logs_file=/dev/null -q "CREATE TABLE imdb_03231.clone_as_foo_merge_tree CLONE AS imdb_03231.foo_merge_tree" 2>&1)" \ - | grep -c 'Code: 344. DB::Exception: .* CREATE CLONE AS is not supported with Replicated databases. Consider using separate CREATE and INSERT queries.' - -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS imdb_03231.clone_as_foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS imdb_03231.foo_merge_tree" -${CLICKHOUSE_CLIENT} -q "DROP DATABASE IF EXISTS imdb_03231" \ No newline at end of file diff --git a/tests/queries/0_stateless/03231_create_with_clone_as.sql b/tests/queries/0_stateless/03231_create_with_clone_as.sql new file mode 100644 index 00000000000..b410c09bb9c --- /dev/null +++ b/tests/queries/0_stateless/03231_create_with_clone_as.sql @@ -0,0 +1,87 @@ +-- Tags: no-replicated-database +-- Tag no-replicated-database: Unsupported type of CREATE TABLE ... CLONE AS ... query + +DROP TABLE IF EXISTS foo_memory; +DROP TABLE IF EXISTS clone_as_foo_memory; +DROP TABLE IF EXISTS foo_file; +DROP TABLE IF EXISTS clone_as_foo_file; +DROP TABLE IF EXISTS foo_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_merge_tree; +DROP TABLE IF EXISTS foo_replacing_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_replacing_merge_tree; +DROP TABLE IF EXISTS foo_replicated_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_replicated_merge_tree; + +-- CLONE AS with a table of Memory engine +CREATE TABLE foo_memory (x Int8, y String) ENGINE=Memory; +SHOW CREATE TABLE foo_memory; +INSERT INTO foo_memory VALUES (1, 'a'), (2, 'b'); + +CREATE TABLE clone_as_foo_memory CLONE AS foo_memory; -- { serverError SUPPORT_IS_DISABLED } + +-- CLONE AS with a table of File engine +CREATE TABLE foo_file (x Int8, y String) ENGINE=File(TabSeparated); +SHOW CREATE TABLE foo_file; +INSERT INTO foo_file VALUES (1, 'a'), (2, 'b'); + +CREATE TABLE clone_as_foo_file CLONE AS foo_file; -- { serverError SUPPORT_IS_DISABLED } + +-- CLONE AS with a table of MergeTree engine +CREATE TABLE foo_merge_tree (x Int8, y String) ENGINE=MergeTree PRIMARY KEY x; +SHOW CREATE TABLE foo_merge_tree; +INSERT INTO foo_merge_tree VALUES (1, 'a'), (2, 'b'); +SELECT * FROM foo_merge_tree; + +CREATE TABLE clone_as_foo_merge_tree CLONE AS foo_merge_tree; +SHOW CREATE TABLE clone_as_foo_merge_tree; +SELECT 'from foo_merge_tree'; +SELECT * FROM foo_merge_tree; +SELECT 'from clone_as_foo_merge_tree'; +SELECT * FROM clone_as_foo_merge_tree; + +-- CLONE AS with a table of ReplacingMergeTree engine +CREATE TABLE foo_replacing_merge_tree (x Int8, y String) ENGINE=ReplacingMergeTree PRIMARY KEY x; +SHOW CREATE TABLE foo_replacing_merge_tree; +INSERT INTO foo_replacing_merge_tree VALUES (1, 'a'), (2, 'b'); +SELECT * FROM foo_replacing_merge_tree; + +CREATE TABLE clone_as_foo_replacing_merge_tree CLONE AS foo_replacing_merge_tree; +SHOW CREATE TABLE clone_as_foo_replacing_merge_tree; +SELECT 'from foo_replacing_merge_tree'; +SELECT * FROM foo_replacing_merge_tree; +SELECT 'from clone_as_foo_replacing_merge_tree'; +SELECT * FROM clone_as_foo_replacing_merge_tree; + +-- CLONE AS with a table of ReplicatedMergeTree engine +CREATE TABLE foo_replicated_merge_tree (x Int8, y String) ENGINE=ReplicatedMergeTree('/clickhouse/tables/{database}/test_foo_replicated_merge_tree', 'r1') PRIMARY KEY x; +SHOW CREATE TABLE foo_replicated_merge_tree; +INSERT INTO foo_replicated_merge_tree VALUES (1, 'a'), (2, 'b'); +SELECT * FROM foo_replicated_merge_tree; +CREATE TABLE clone_as_foo_replicated_merge_tree CLONE AS foo_replicated_merge_tree; -- { serverError SUPPORT_IS_DISABLED } + +DROP TABLE IF EXISTS foo_memory; +DROP TABLE IF EXISTS clone_as_foo_memory; +DROP TABLE IF EXISTS foo_file; +DROP TABLE IF EXISTS clone_as_foo_file; +DROP TABLE IF EXISTS foo_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_merge_tree; +DROP TABLE IF EXISTS foo_replacing_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_replacing_merge_tree; +DROP TABLE IF EXISTS foo_replicated_merge_tree; +DROP TABLE IF EXISTS clone_as_foo_replicated_merge_tree; + +-- CLONE AS with a Replicated database +DROP DATABASE IF EXISTS imdb_03231; + +CREATE DATABASE imdb_03231 ENGINE = Replicated('/test/databases/{database}/imdb_03231', 's1', 'r1'); + +CREATE TABLE imdb_03231.foo_merge_tree (x Int8, y String) ENGINE=MergeTree PRIMARY KEY x; +SHOW CREATE TABLE imdb_03231.foo_merge_tree; +INSERT INTO imdb_03231.foo_merge_tree VALUES (1, 'a'), (2, 'b'); +SELECT 'from imdb_03231.foo_merge_tree'; +SELECT * FROM imdb_03231.foo_merge_tree; +CREATE TABLE imdb_03231.clone_as_foo_merge_tree CLONE AS imdb_03231.foo_merge_tree; -- { serverError SUPPORT_IS_DISABLED } + +DROP TABLE IF EXISTS imdb_03231.clone_as_foo_merge_tree; +DROP TABLE IF EXISTS imdb_03231.foo_merge_tree; +DROP DATABASE IF EXISTS imdb_03231; \ No newline at end of file