2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: shard
|
|
|
|
|
2021-02-02 02:25:19 +00:00
|
|
|
DROP TABLE IF EXISTS x;
|
2021-02-02 06:06:17 +00:00
|
|
|
DROP TABLE IF EXISTS x_dist;
|
|
|
|
DROP TABLE IF EXISTS y;
|
|
|
|
DROP TABLE IF EXISTS y_dist;
|
2021-02-02 02:25:19 +00:00
|
|
|
|
|
|
|
CREATE TABLE x AS system.numbers ENGINE = MergeTree ORDER BY number;
|
2021-02-02 06:06:17 +00:00
|
|
|
CREATE TABLE y AS system.numbers ENGINE = MergeTree ORDER BY number;
|
2021-02-02 02:25:19 +00:00
|
|
|
|
|
|
|
CREATE TABLE x_dist as x ENGINE = Distributed('test_cluster_two_shards', currentDatabase(), x);
|
2021-02-02 06:06:17 +00:00
|
|
|
CREATE TABLE y_dist as y ENGINE = Distributed('test_cluster_two_shards_localhost', currentDatabase(), y);
|
2021-02-02 02:25:19 +00:00
|
|
|
|
|
|
|
-- insert into first shard
|
|
|
|
INSERT INTO x_dist SELECT * FROM numbers(10) settings insert_shard_id = 1;
|
2021-02-02 06:06:17 +00:00
|
|
|
INSERT INTO y_dist SELECT * FROM numbers(10) settings insert_shard_id = 1;
|
|
|
|
|
|
|
|
SELECT * FROM x_dist ORDER by number;
|
|
|
|
SELECT * FROM y_dist ORDER by number;
|
2021-02-02 02:25:19 +00:00
|
|
|
|
|
|
|
-- insert into second shard
|
|
|
|
INSERT INTO x_dist SELECT * FROM numbers(10, 10) settings insert_shard_id = 2;
|
2021-02-02 06:06:17 +00:00
|
|
|
INSERT INTO y_dist SELECT * FROM numbers(10, 10) settings insert_shard_id = 2;
|
2021-02-02 02:25:19 +00:00
|
|
|
|
2021-02-02 06:06:17 +00:00
|
|
|
SELECT * FROM x_dist ORDER by number;
|
|
|
|
SELECT * FROM y_dist ORDER by number;
|
2021-02-02 02:25:19 +00:00
|
|
|
|
2021-02-02 06:06:17 +00:00
|
|
|
-- no sharding key
|
|
|
|
INSERT INTO x_dist SELECT * FROM numbers(10); -- { serverError 55 }
|
|
|
|
INSERT INTO y_dist SELECT * FROM numbers(10); -- { serverError 55 }
|
2021-02-02 02:25:19 +00:00
|
|
|
|
2021-02-02 06:06:17 +00:00
|
|
|
-- invalid shard id
|
2021-03-12 10:28:04 +00:00
|
|
|
INSERT INTO x_dist SELECT * FROM numbers(10) settings insert_shard_id = 3; -- { serverError 577 }
|
|
|
|
INSERT INTO y_dist SELECT * FROM numbers(10) settings insert_shard_id = 3; -- { serverError 577 }
|
2021-02-02 02:25:19 +00:00
|
|
|
|
|
|
|
DROP TABLE x;
|
|
|
|
DROP TABLE x_dist;
|
2021-02-02 06:06:17 +00:00
|
|
|
DROP TABLE y;
|
|
|
|
DROP TABLE y_dist;
|