mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix
This commit is contained in:
parent
7ae5e51ee9
commit
91068b782b
@ -344,6 +344,17 @@ String DatabaseReplicatedTask::getShardID() const
|
||||
return database->shard_name;
|
||||
}
|
||||
|
||||
void DatabaseReplicatedTask::parseQueryFromEntry(const Context & context)
|
||||
{
|
||||
DDLTaskBase::parseQueryFromEntry(context);
|
||||
if (auto * ddl_query = dynamic_cast<ASTQueryWithTableAndOutput *>(query.get()))
|
||||
{
|
||||
/// Update database name with actual name of local database
|
||||
assert(ddl_query->database.empty());
|
||||
ddl_query->database = database->getDatabaseName();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Context> DatabaseReplicatedTask::makeQueryContext(Context & from_context, const ZooKeeperPtr & zookeeper)
|
||||
{
|
||||
auto query_context = DDLTaskBase::makeQueryContext(from_context, zookeeper);
|
||||
|
@ -93,7 +93,7 @@ struct DDLTaskBase
|
||||
DDLTaskBase(const DDLTaskBase &) = delete;
|
||||
virtual ~DDLTaskBase() = default;
|
||||
|
||||
void parseQueryFromEntry(const Context & context);
|
||||
virtual void parseQueryFromEntry(const Context & context);
|
||||
|
||||
virtual String getShardID() const = 0;
|
||||
|
||||
@ -134,6 +134,7 @@ struct DatabaseReplicatedTask : public DDLTaskBase
|
||||
DatabaseReplicatedTask(const String & name, const String & path, DatabaseReplicated * database_);
|
||||
|
||||
String getShardID() const override;
|
||||
void parseQueryFromEntry(const Context & context) override;
|
||||
std::unique_ptr<Context> makeQueryContext(Context & from_context, const ZooKeeperPtr & zookeeper) override;
|
||||
|
||||
DatabaseReplicated * database;
|
||||
|
@ -35,8 +35,17 @@ def started_cluster():
|
||||
cluster.shutdown()
|
||||
|
||||
def test_create_replicated_table(started_cluster):
|
||||
assert "Explicit zookeeper_path and replica_name are specified" in \
|
||||
main_node.query_and_get_error("CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) "
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp', 'r') ORDER BY k PARTITION BY toYYYYMM(d);")
|
||||
|
||||
assert "Explicit zookeeper_path and replica_name are specified" in \
|
||||
main_node.query_and_get_error("CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) "
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp', 'r', d, k, 8192);")
|
||||
|
||||
assert "Old syntax is not allowed" in \
|
||||
main_node.query_and_get_error("CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree('/test/tmp', 'r', d, k, 8192);")
|
||||
main_node.query_and_get_error("CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) "
|
||||
"ENGINE=ReplicatedMergeTree('/test/tmp/{shard}', '{replica}', d, k, 8192);")
|
||||
|
||||
main_node.query("CREATE TABLE testdb.replicated_table (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree ORDER BY k PARTITION BY toYYYYMM(d);")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user