mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge
This commit is contained in:
parent
0e57c8c423
commit
fb654a1255
@ -142,6 +142,9 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
|
|||||||
|
|
||||||
if (!attach)
|
if (!attach)
|
||||||
{
|
{
|
||||||
|
if (!data.getDataParts().empty())
|
||||||
|
throw Exception("Data directory for table already containing data parts - probably it was unclean DROP table or manual intervention. You must either clear directory by hand or use ATTACH TABLE instead of CREATE TABLE if you need to use that parts.", ErrorCodes::INCORRECT_DATA);
|
||||||
|
|
||||||
createTableIfNotExists();
|
createTableIfNotExists();
|
||||||
|
|
||||||
checkTableStructure(false, false);
|
checkTableStructure(false, false);
|
||||||
@ -241,21 +244,24 @@ void StorageReplicatedMergeTree::createTableIfNotExists()
|
|||||||
zookeeper->createAncestors(zookeeper_path);
|
zookeeper->createAncestors(zookeeper_path);
|
||||||
|
|
||||||
/// Запишем метаданные таблицы, чтобы реплики могли сверять с ними параметры таблицы.
|
/// Запишем метаданные таблицы, чтобы реплики могли сверять с ними параметры таблицы.
|
||||||
std::stringstream metadata;
|
std::string metadata;
|
||||||
metadata << "metadata format version: 1" << std::endl;
|
{
|
||||||
metadata << "date column: " << data.date_column_name << std::endl;
|
WriteBufferFromString out(metadata);
|
||||||
metadata << "sampling expression: " << formattedAST(data.sampling_expression) << std::endl;
|
out << "metadata format version: 1" << "\n"
|
||||||
metadata << "index granularity: " << data.index_granularity << std::endl;
|
<< "date column: " << data.date_column_name << "\n"
|
||||||
metadata << "mode: " << static_cast<int>(data.mode) << std::endl;
|
<< "sampling expression: " << formattedAST(data.sampling_expression) << "\n"
|
||||||
metadata << "sign column: " << data.sign_column << std::endl;
|
<< "index granularity: " << data.index_granularity << "\n"
|
||||||
metadata << "primary key: " << formattedAST(data.primary_expr_ast) << std::endl;
|
<< "mode: " << static_cast<int>(data.mode) << "\n"
|
||||||
|
<< "sign column: " << data.sign_column << "\n"
|
||||||
|
<< "primary key: " << formattedAST(data.primary_expr_ast) << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
auto acl = zookeeper->getDefaultACL();
|
auto acl = zookeeper->getDefaultACL();
|
||||||
|
|
||||||
zkutil::Ops ops;
|
zkutil::Ops ops;
|
||||||
ops.push_back(new zkutil::Op::Create(zookeeper_path, "",
|
ops.push_back(new zkutil::Op::Create(zookeeper_path, "",
|
||||||
acl, zkutil::CreateMode::Persistent));
|
acl, zkutil::CreateMode::Persistent));
|
||||||
ops.push_back(new zkutil::Op::Create(zookeeper_path + "/metadata", metadata.str(),
|
ops.push_back(new zkutil::Op::Create(zookeeper_path + "/metadata", metadata,
|
||||||
acl, zkutil::CreateMode::Persistent));
|
acl, zkutil::CreateMode::Persistent));
|
||||||
ops.push_back(new zkutil::Op::Create(zookeeper_path + "/columns", ColumnsDescription<false>{
|
ops.push_back(new zkutil::Op::Create(zookeeper_path + "/columns", ColumnsDescription<false>{
|
||||||
data.getColumnsListNonMaterialized(), data.materialized_columns,
|
data.getColumnsListNonMaterialized(), data.materialized_columns,
|
||||||
|
Loading…
Reference in New Issue
Block a user