| 197 | } |
| 198 | |
| 199 | void CnchServerResource::addCreateQuery( |
| 200 | const ContextPtr & context, |
| 201 | const StoragePtr & storage, |
| 202 | const String & create_query, |
| 203 | const String & worker_table_name, |
| 204 | bool create_local_table) |
| 205 | { |
| 206 | /// table should exists in SelectStreamFactory::createForShard |
| 207 | /// so we create table in worker in advance |
| 208 | if (context->getServerType() == ServerType::cnch_worker && create_local_table) |
| 209 | { |
| 210 | auto temp_context = Context::createCopy(context); |
| 211 | auto worker_resource = context->getCnchWorkerResource(); |
| 212 | worker_resource->executeCreateQuery(temp_context, create_query, /* skip_if_exists */ true); |
| 213 | } |
| 214 | |
| 215 | auto lock = getLock(); |
| 216 | |
| 217 | auto it = assigned_table_resource.find(storage->getStorageUUID()); |
| 218 | if(storage->getStorageUUID() == UUIDHelpers::Nil) |
| 219 | { |
| 220 | // throw DB::Exception(ErrorCodes::LOGICAL_ERROR, "UUID for resources should not be nil"); |
| 221 | LOG_DEBUG(log, "UUID for resources should not be nil, query: {}, table: {}", create_query, worker_table_name); |
| 222 | } |
| 223 | if (it == assigned_table_resource.end()) |
| 224 | it = assigned_table_resource.emplace(storage->getStorageUUID(), AssignedResource{storage}).first; |
| 225 | |
| 226 | it->second.table_definition.definition = create_query; |
| 227 | it->second.table_definition.local_table_name = worker_table_name; |
| 228 | it->second.table_definition.cacheable = false; |
| 229 | } |
| 230 | |
| 231 | void CnchServerResource::addCacheableCreateQuery( |
| 232 | const StoragePtr & storage, |
no test coverage detected