2022-01-10 18:21:25 +00:00
|
|
|
-- { echoOn }
|
|
|
|
|
|
|
|
-- remote(system.one)
|
|
|
|
SELECT 'remote(system.one)';
|
2019-09-18 21:17:00 +00:00
|
|
|
remote(system.one)
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT * FROM remote('127.0.0.1', system.one);
|
2019-09-18 21:17:00 +00:00
|
|
|
0
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT * FROM remote('127.0.0.{1,2}', system.one);
|
2019-09-18 21:17:00 +00:00
|
|
|
0
|
|
|
|
0
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, * FROM remote('127.0.0.1', system.one);
|
2019-09-18 21:17:00 +00:00
|
|
|
1 0
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, * FROM remote('127.0.0.{1,2}', system.one) order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 0
|
|
|
|
2 0
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, * FROM remote('127.0.0.{1,2}', system.one) WHERE _shard_num = 1;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 0
|
2022-01-10 18:21:25 +00:00
|
|
|
-- dist_1 using test_shard_localhost
|
|
|
|
SELECT 'dist_1';
|
2019-09-18 21:17:00 +00:00
|
|
|
dist_1
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num FROM dist_1 order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
1
|
2022-01-10 18:21:25 +00:00
|
|
|
1
|
|
|
|
SELECT _shard_num FROM dist_1 order by _shard_num;
|
|
|
|
1
|
|
|
|
1
|
|
|
|
SELECT _shard_num, key FROM dist_1 order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 10
|
2022-01-10 18:21:25 +00:00
|
|
|
1 20
|
|
|
|
SELECT key FROM dist_1;
|
2019-09-18 21:17:00 +00:00
|
|
|
10
|
2022-01-10 18:21:25 +00:00
|
|
|
20
|
|
|
|
SELECT _shard_num FROM dist_1 order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
1
|
|
|
|
1
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, key FROM dist_1 order by _shard_num, key;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 10
|
|
|
|
1 20
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT key FROM dist_1;
|
2019-09-18 21:17:00 +00:00
|
|
|
10
|
|
|
|
20
|
2022-01-10 18:21:25 +00:00
|
|
|
-- dist_2 using test_cluster_two_shards_localhost
|
|
|
|
SELECT 'dist_2';
|
2019-09-18 21:17:00 +00:00
|
|
|
dist_2
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num FROM dist_2 order by _shard_num;
|
|
|
|
1
|
|
|
|
2
|
|
|
|
SELECT _shard_num FROM dist_2 order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
1
|
|
|
|
2
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, key FROM dist_2 order by _shard_num, key;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 100
|
|
|
|
2 100
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT key FROM dist_2;
|
2019-09-18 21:17:00 +00:00
|
|
|
100
|
|
|
|
100
|
2022-01-10 18:21:25 +00:00
|
|
|
-- multiple _shard_num
|
|
|
|
SELECT 'remote(Distributed)';
|
2019-09-18 21:17:00 +00:00
|
|
|
remote(Distributed)
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, key FROM remote('127.0.0.1', currentDatabase(), dist_2) order by _shard_num, key;
|
2019-09-18 21:17:00 +00:00
|
|
|
1 100
|
2022-01-10 18:21:24 +00:00
|
|
|
2 100
|
2022-01-10 18:21:25 +00:00
|
|
|
-- JOIN system.clusters
|
|
|
|
SELECT 'JOIN system.clusters';
|
2019-09-18 21:17:00 +00:00
|
|
|
JOIN system.clusters
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT a._shard_num, a.key, b.host_name, b.host_address IN ('::1', '127.0.0.1'), b.port
|
|
|
|
FROM (SELECT *, _shard_num FROM dist_1) a
|
|
|
|
JOIN system.clusters b
|
|
|
|
ON a._shard_num = b.shard_num
|
|
|
|
WHERE b.cluster = 'test_cluster_two_shards_localhost';
|
2021-05-05 22:14:32 +00:00
|
|
|
1 10 localhost 1 9000
|
|
|
|
1 20 localhost 1 9000
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, key, b.host_name, b.host_address IN ('::1', '127.0.0.1'), b.port
|
|
|
|
FROM dist_1 a
|
|
|
|
JOIN system.clusters b
|
|
|
|
ON _shard_num = b.shard_num
|
|
|
|
WHERE b.cluster = 'test_cluster_two_shards_localhost'; -- { serverError 403 }
|
|
|
|
SELECT 'Rewrite with alias';
|
2022-01-10 18:21:24 +00:00
|
|
|
Rewrite with alias
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT a._shard_num, key FROM dist_1 a;
|
2022-01-10 18:21:24 +00:00
|
|
|
1 10
|
|
|
|
1 20
|
2022-01-10 18:21:25 +00:00
|
|
|
-- the same with JOIN, just in case
|
|
|
|
SELECT a._shard_num, a.key, b.host_name, b.host_address IN ('::1', '127.0.0.1'), b.port
|
|
|
|
FROM dist_1 a
|
|
|
|
JOIN system.clusters b
|
|
|
|
ON a._shard_num = b.shard_num
|
|
|
|
WHERE b.cluster = 'test_cluster_two_shards_localhost'; -- { serverError 47; }
|
|
|
|
SELECT 'dist_3';
|
2019-09-18 21:17:00 +00:00
|
|
|
dist_3
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT * FROM dist_3;
|
2019-09-18 21:17:00 +00:00
|
|
|
100 foo
|
2022-01-10 18:21:25 +00:00
|
|
|
SELECT _shard_num, * FROM dist_3 order by _shard_num;
|
2019-09-18 21:17:00 +00:00
|
|
|
foo 100 foo
|