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

Method tryCreateDestinationTable

programs/copier/ClusterCopier.cpp:1140–1172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138}
1139
1140TaskStatus ClusterCopier::tryCreateDestinationTable(const ConnectionTimeouts & timeouts, TaskTable & task_table)
1141{
1142 /// Try create original table (if not exists) on each shard
1143
1144 //TaskTable & task_table = task_shard.task_table;
1145 const TaskShardPtr task_shard = task_table.all_shards.at(0);
1146 /// We need to update table definitions for each part, it could be changed after ALTER
1147 task_shard->current_pull_table_create_query = getCreateTableForPullShard(timeouts, *task_shard);
1148 try
1149 {
1150 auto create_query_push_ast
1151 = rewriteCreateQueryStorage(task_shard->current_pull_table_create_query, task_table.table_push, task_table.engine_push_ast);
1152 auto & create = create_query_push_ast->as<ASTCreateQuery &>();
1153 create.if_not_exists = true;
1154 InterpreterCreateQuery::prepareOnClusterQuery(create, getContext(), task_table.cluster_push_name);
1155 String query = queryToString(create_query_push_ast);
1156
1157 LOG_INFO(log, "Create destination tables. Query: \n {}", query);
1158 UInt64 shards = executeQueryOnCluster(task_table.cluster_push, query, task_cluster->settings_push, ClusterExecutionMode::ON_EACH_NODE);
1159 LOG_INFO(
1160 log,
1161 "Destination tables {} have been created on {} shards of {}",
1162 getQuotedTable(task_table.table_push),
1163 shards,
1164 task_table.cluster_push->getShardCount());
1165 }
1166 catch (...)
1167 {
1168 tryLogCurrentException(log, "Error while creating original table. Maybe we are not first.");
1169 }
1170
1171 return TaskStatus::Finished;
1172}
1173
1174/// Job for copying partition from particular shard.
1175TaskStatus ClusterCopier::tryProcessPartitionTask(const ConnectionTimeouts & timeouts, ShardPartition & task_partition, bool is_unprioritized_task)

Callers

nothing calls this directly

Calls 6

queryToStringFunction · 0.85
getQuotedTableFunction · 0.85
tryLogCurrentExceptionFunction · 0.85
atMethod · 0.45
getShardCountMethod · 0.45

Tested by

no test coverage detected