MCPcopy Create free account
hub / github.com/ByConity/ByConity / rewriteCreateQueryStorage

Function rewriteCreateQueryStorage

programs/copier/ClusterCopier.cpp:754–774  ·  view source on GitHub ↗

Replaces ENGINE and table name in a create query

Source from the content-addressed store, hash-verified

752
753/// Replaces ENGINE and table name in a create query
754std::shared_ptr<ASTCreateQuery> rewriteCreateQueryStorage(const ASTPtr & create_query_ast,
755 const DatabaseAndTableName & new_table,
756 const ASTPtr & new_storage_ast)
757{
758 const auto & create = create_query_ast->as<ASTCreateQuery &>();
759 auto res = std::make_shared<ASTCreateQuery>(create);
760
761 if (create.storage == nullptr || new_storage_ast == nullptr)
762 throw Exception("Storage is not specified", ErrorCodes::LOGICAL_ERROR);
763
764 res->database = new_table.first;
765 res->table = new_table.second;
766
767 res->children.clear();
768 res->set(res->columns_list, create.columns_list->clone());
769 res->set(res->storage, new_storage_ast->clone());
770 /// Just to make it better and don't store additional flag like `is_table_created` somewhere else
771 res->if_not_exists = true;
772
773 return res;
774}
775
776
777bool ClusterCopier::tryDropPartitionPiece(

Calls 4

ExceptionClass · 0.50
clearMethod · 0.45
setMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected