mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
return back virtual columns to distributed tables
This commit is contained in:
parent
0bfc280f0d
commit
e87de3cfcd
@ -290,6 +290,10 @@ VirtualColumnsDescription StorageDistributed::createVirtuals()
|
||||
|
||||
desc.addEphemeral("_shard_num", std::make_shared<DataTypeUInt32>(), "Deprecated. Use function shardNum instead");
|
||||
|
||||
/// Add virtual columns from table of storage Merges.
|
||||
desc.addEphemeral("_database", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "The name of database which the row comes from");
|
||||
desc.addEphemeral("_table", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "The name of table which the row comes from");
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
1 t_local_1
|
||||
2 t_local_2
|
||||
1 t_local_1
|
||||
2 t_local_2
|
||||
1 1
|
||||
2 1
|
||||
1 1
|
||||
2 1
|
@ -0,0 +1,24 @@
|
||||
DROP TABLE IF EXISTS t_local_1;
|
||||
DROP TABLE IF EXISTS t_local_2;
|
||||
DROP TABLE IF EXISTS t_merge;
|
||||
DROP TABLE IF EXISTS t_distr;
|
||||
|
||||
CREATE TABLE t_local_1 (a UInt32) ENGINE = MergeTree ORDER BY a;
|
||||
CREATE TABLE t_local_2 (a UInt32) ENGINE = MergeTree ORDER BY a;
|
||||
|
||||
INSERT INTO t_local_1 VALUES (1);
|
||||
INSERT INTO t_local_2 VALUES (2);
|
||||
|
||||
CREATE TABLE t_merge AS t_local_1 ENGINE = Merge(currentDatabase(), '^(t_local_1|t_local_2)$');
|
||||
CREATE TABLE t_distr AS t_local_1 engine=Distributed('test_shard_localhost', currentDatabase(), t_merge, rand());
|
||||
|
||||
SELECT a, _table FROM t_merge ORDER BY a;
|
||||
SELECT a, _table FROM t_distr ORDER BY a;
|
||||
|
||||
SELECT a, _database = currentDatabase() FROM t_merge ORDER BY a;
|
||||
SELECT a, _database = currentDatabase() FROM t_distr ORDER BY a;
|
||||
|
||||
DROP TABLE IF EXISTS t_local_1;
|
||||
DROP TABLE IF EXISTS t_local_2;
|
||||
DROP TABLE IF EXISTS t_merge;
|
||||
DROP TABLE IF EXISTS t_distr;
|
Loading…
Reference in New Issue
Block a user