2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: distributed
|
|
|
|
|
2020-06-20 11:29:01 +00:00
|
|
|
SET send_logs_level = 'fatal';
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS test_local_1;
|
|
|
|
DROP TABLE IF EXISTS test_local_2;
|
|
|
|
DROP TABLE IF EXISTS test_distributed_1;
|
|
|
|
DROP TABLE IF EXISTS test_distributed_2;
|
2018-09-08 11:29:23 +00:00
|
|
|
|
2022-06-23 08:37:52 +00:00
|
|
|
set allow_deprecated_syntax_for_merge_tree=1;
|
2019-06-07 15:41:24 +00:00
|
|
|
CREATE TABLE test_local_1 (date Date, value UInt32) ENGINE = MergeTree(date, date, 8192);
|
|
|
|
CREATE TABLE test_local_2 (date Date, value UInt32) ENGINE = MergeTree(date, date, 8192);
|
|
|
|
CREATE TABLE test_distributed_1 AS test_local_1 ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_local_1, rand());
|
|
|
|
CREATE TABLE test_distributed_2 AS test_local_2 ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_local_2, rand());
|
2018-09-08 11:29:23 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
INSERT INTO test_local_1 VALUES ('2018-08-01',100);
|
|
|
|
INSERT INTO test_local_2 VALUES ('2018-08-01',200);
|
2018-09-08 11:29:23 +00:00
|
|
|
|
2018-09-18 11:09:21 +00:00
|
|
|
SELECT '--------------Single Local------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1');
|
|
|
|
SELECT *, _table FROM merge(currentDatabase(), 'test_local_1') ORDER BY _table;
|
|
|
|
SELECT sum(value), _table FROM merge(currentDatabase(), 'test_local_1') GROUP BY _table ORDER BY _table;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1') WHERE _table = 'test_local_1';
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1') PREWHERE _table = 'test_local_1'; -- { serverError NOT_FOUND_COLUMN_IN_BLOCK }
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1') WHERE _table in ('test_local_1', 'test_local_2');
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1') PREWHERE _table in ('test_local_1', 'test_local_2'); -- { serverError NOT_FOUND_COLUMN_IN_BLOCK }
|
2018-09-18 11:09:21 +00:00
|
|
|
|
|
|
|
SELECT '--------------Single Distributed------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1');
|
|
|
|
SELECT *, _table FROM merge(currentDatabase(), 'test_distributed_1') ORDER BY _table;
|
|
|
|
SELECT sum(value), _table FROM merge(currentDatabase(), 'test_distributed_1') GROUP BY _table ORDER BY _table;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1') WHERE _table = 'test_distributed_1';
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1') PREWHERE _table = 'test_distributed_1'; -- { serverError ILLEGAL_PREWHERE }
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1') WHERE _table in ('test_distributed_1', 'test_distributed_2');
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1') PREWHERE _table in ('test_distributed_1', 'test_distributed_2'); -- { serverError ILLEGAL_PREWHERE }
|
2018-09-18 11:09:21 +00:00
|
|
|
|
|
|
|
SELECT '--------------Local Merge Local------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_local_2') ORDER BY _table;
|
|
|
|
SELECT *, _table FROM merge(currentDatabase(), 'test_local_1|test_local_2') ORDER BY _table;
|
|
|
|
SELECT sum(value), _table FROM merge(currentDatabase(), 'test_local_1|test_local_2') GROUP BY _table ORDER BY _table;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_local_2') WHERE _table = 'test_local_1';
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_local_2') PREWHERE _table = 'test_local_1'; -- { serverError NOT_FOUND_COLUMN_IN_BLOCK }
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_local_2') WHERE _table in ('test_local_1', 'test_local_2') ORDER BY value;
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_local_2') PREWHERE _table in ('test_local_1', 'test_local_2') ORDER BY value; -- { serverError NOT_FOUND_COLUMN_IN_BLOCK }
|
2018-09-18 11:09:21 +00:00
|
|
|
|
|
|
|
SELECT '--------------Local Merge Distributed------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') ORDER BY _table;
|
|
|
|
SELECT *, _table FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') ORDER BY _table;
|
|
|
|
SELECT sum(value), _table FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') GROUP BY _table ORDER BY _table;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') WHERE _table = 'test_local_1';
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') PREWHERE _table = 'test_local_1'; -- { serverError ILLEGAL_PREWHERE }
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') WHERE _table in ('test_local_1', 'test_distributed_2') ORDER BY value;
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_local_1|test_distributed_2') PREWHERE _table in ('test_local_1', 'test_distributed_2') ORDER BY value; -- { serverError ILLEGAL_PREWHERE }
|
2018-09-18 11:09:21 +00:00
|
|
|
|
|
|
|
SELECT '--------------Distributed Merge Distributed------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') ORDER BY _table;
|
|
|
|
SELECT *, _table FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') ORDER BY _table;
|
|
|
|
SELECT sum(value), _table FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') GROUP BY _table ORDER BY _table;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') WHERE _table = 'test_distributed_1';
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') PREWHERE _table = 'test_distributed_1'; -- { serverError ILLEGAL_PREWHERE }
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') WHERE _table in ('test_distributed_1', 'test_distributed_2') ORDER BY value;
|
2023-01-17 07:34:39 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_distributed_1|test_distributed_2') PREWHERE _table in ('test_distributed_1', 'test_distributed_2') ORDER BY value; -- { serverError ILLEGAL_PREWHERE }
|
2018-09-08 11:29:23 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS test_local_1;
|
|
|
|
DROP TABLE IF EXISTS test_local_2;
|
|
|
|
DROP TABLE IF EXISTS test_distributed_1;
|
|
|
|
DROP TABLE IF EXISTS test_distributed_2;
|
2018-09-20 05:40:06 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS test_u64_local;
|
|
|
|
DROP TABLE IF EXISTS test_s64_local;
|
|
|
|
DROP TABLE IF EXISTS test_u64_distributed;
|
|
|
|
DROP TABLE IF EXISTS test_s64_distributed;
|
2018-09-20 05:40:06 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
CREATE TABLE test_s64_local (date Date, value Int64) ENGINE = MergeTree(date, date, 8192);
|
|
|
|
CREATE TABLE test_u64_local (date Date, value UInt64) ENGINE = MergeTree(date, date, 8192);
|
|
|
|
CREATE TABLE test_s64_distributed AS test_s64_local ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_s64_local, rand());
|
|
|
|
CREATE TABLE test_u64_distributed AS test_u64_local ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_u64_local, rand());
|
2018-09-20 05:40:06 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
INSERT INTO test_s64_local VALUES ('2018-08-01', -1);
|
|
|
|
INSERT INTO test_u64_local VALUES ('2018-08-01', 1);
|
2018-09-20 05:40:06 +00:00
|
|
|
|
|
|
|
SELECT '--------------Implicit type conversion------------';
|
2019-06-07 15:41:24 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_s64_distributed|test_u64_distributed') ORDER BY value;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_s64_distributed|test_u64_distributed') WHERE date = '2018-08-01' ORDER BY value;
|
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_s64_distributed|test_u64_distributed') WHERE _table = 'test_u64_distributed' ORDER BY value;
|
2019-11-08 21:37:33 +00:00
|
|
|
SELECT * FROM merge(currentDatabase(), 'test_s64_distributed|test_u64_distributed') WHERE value = 1;
|
2018-09-20 05:40:06 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS test_u64_local;
|
|
|
|
DROP TABLE IF EXISTS test_s64_local;
|
|
|
|
DROP TABLE IF EXISTS test_u64_distributed;
|
|
|
|
DROP TABLE IF EXISTS test_s64_distributed;
|