mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-19 16:20:50 +00:00
Use ATTACH PARTITION ALL to copy data from the source table
This commit is contained in:
parent
4b3da04f6c
commit
782353d831
@ -1957,27 +1957,20 @@ BlockIO InterpreterCreateQuery::fillTableIfNeeded(const ASTCreateQuery & create)
|
||||
return {};
|
||||
}
|
||||
|
||||
auto command_list = std::make_shared<ASTExpressionList>();
|
||||
for (const auto & partition_id : merge_tree_table->getAllPartitionIds())
|
||||
{
|
||||
auto partition = std::make_shared<ASTPartition>();
|
||||
partition->all = false;
|
||||
partition->setPartitionID(std::make_shared<ASTLiteral>(partition_id));
|
||||
partition->all = true;
|
||||
|
||||
auto command = std::make_shared<ASTAlterCommand>();
|
||||
command->replace = false;
|
||||
|
||||
command->type = ASTAlterCommand::REPLACE_PARTITION;
|
||||
command->partition = command->children.emplace_back(std::move(partition)).get();
|
||||
|
||||
command->from_database = as_database_name;
|
||||
command->from_table = as_table_saved;
|
||||
|
||||
command->to_database = create.getDatabase();
|
||||
command->to_table = create.getTable();
|
||||
|
||||
auto command_list = std::make_shared<ASTExpressionList>();
|
||||
command_list->children.push_back(command);
|
||||
}
|
||||
|
||||
auto query = std::make_shared<ASTAlterQuery>();
|
||||
query->database = create.database;
|
||||
|
@ -54,9 +54,7 @@ ${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SHOW CREATE TABLE clone_as_f
|
||||
echo "from foo_replacing_merge_tree"
|
||||
${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM foo_replacing_merge_tree"
|
||||
echo "from clone_as_foo_replacing_merge_tree"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT mutation_id, command, block_numbers.partition_id, block_numbers.number, parts_to_do, is_done FROM system.mutations WHERE database = '$CLICKHOUSE_DATABASE' and table = 'clone_as_foo_replacing_merge_tree' ORDER BY mutation_id"
|
||||
${CLICKHOUSE_CLIENT} --optimize_throw_if_noop 1 -q "SELECT * FROM clone_as_foo_replacing_merge_tree FINAL"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT mutation_id, command, block_numbers.partition_id, block_numbers.number, parts_to_do, is_done FROM system.mutations WHERE database = '$CLICKHOUSE_DATABASE' and table = 'clone_as_foo_replacing_merge_tree' ORDER BY mutation_id"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS foo_memory"
|
||||
${CLICKHOUSE_CLIENT} -q "DROP TABLE IF EXISTS clone_as_foo_memory"
|
||||
|
Loading…
Reference in New Issue
Block a user