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

Method getCreateQueryForCloudTable

src/MergeTreeCommon/CnchStorageCommon.cpp:302–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302String CnchStorageCommonHelper::getCreateQueryForCloudTable(
303 const String & query,
304 const String & local_table_name,
305 const ContextPtr & /*context*/,
306 bool enable_staging_area,
307 const std::optional<StorageID> & cnch_storage_id,
308 const Strings & engine_args,
309 const String & local_database_name,
310 WorkerEngineType engine_type) const
311{
312 ParserCreateQuery parser;
313 ASTPtr ast = parseQuery(parser, query.data(), query.data() + query.size(), "", 0, DBMS_DEFAULT_MAX_PARSER_DEPTH);
314
315 auto & create_query = ast->as<ASTCreateQuery &>();
316 create_query.table = local_table_name;
317 if (!local_database_name.empty())
318 create_query.database = local_database_name;
319
320 replaceCnchWithCloud(
321 create_query.storage,
322 cnch_storage_id.value_or(table_id).getDatabaseName(),
323 cnch_storage_id.value_or(table_id).getTableName(),
324 engine_type,
325 engine_args);
326
327 // perhaps better to enable if_not_exists by default
328 if (engine_type == WorkerEngineType::DICT)
329 create_query.if_not_exists = true;
330
331 if (enable_staging_area)
332 modifyOrAddSetting(create_query, "cloud_enable_staging_area", Field(UInt64(1)));
333
334 WriteBufferFromOwnString statement_buf;
335 formatAST(create_query, statement_buf, false);
336 writeChar('\n', statement_buf);
337 LOG_TRACE(
338 &Poco::Logger::get("getCreateQueryForCloudTable"), "create query for cloud table is {}", statement_buf.str());
339 return statement_buf.str();
340}
341
342bool CnchStorageCommonHelper::forwardQueryToServerIfNeeded(ContextPtr query_context, const StorageID & storage_id, const String & query_to_forward, bool need_process_entry) const
343{

Callers 5

TESTFunction · 0.80
getTableMethod · 0.80

Calls 14

parseQueryFunction · 0.85
replaceCnchWithCloudFunction · 0.85
modifyOrAddSettingFunction · 0.85
formatASTFunction · 0.85
writeCharFunction · 0.85
value_orMethod · 0.80
FieldClass · 0.50
getFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
getDatabaseNameMethod · 0.45

Tested by 1

TESTFunction · 0.64