MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getCreateTableQueryImpl

Method getCreateTableQueryImpl

src/Databases/DatabaseOnDisk.cpp:538–561  ·  view source on GitHub ↗

It returns the create table statement (even if table is detached)

Source from the content-addressed store, hash-verified

536
537/// It returns the create table statement (even if table is detached)
538ASTPtr DatabaseOnDisk::getCreateTableQueryImpl(const String & table_name, ContextPtr, bool throw_on_error) const
539{
540 ASTPtr ast;
541 StoragePtr storage = tryGetTable(table_name, getContext());
542 bool has_table = storage != nullptr;
543 bool is_system_storage = false;
544 if (has_table)
545 is_system_storage = storage->isSystemStorage();
546
547 try
548 {
549 ast = getCreateQueryFromMetadata(table_name, throw_on_error);
550 }
551 catch (const Exception & e)
552 {
553 if (!has_table && e.code() == ErrorCodes::FILE_DOESNT_EXIST && throw_on_error)
554 throw Exception(ErrorCodes::CANNOT_GET_CREATE_TABLE_QUERY, "Table {} doesn't exist", backQuote(table_name));
555 if (!is_system_storage && throw_on_error)
556 throw;
557 }
558 if (!ast && is_system_storage)
559 ast = getCreateQueryFromStorage(table_name, storage, throw_on_error);
560 return ast;
561}
562
563ASTPtr DatabaseOnDisk::getCreateDatabaseQueryImpl() const
564{

Callers

nothing calls this directly

Calls 7

tryGetTableFunction · 0.85
backQuoteFunction · 0.85
getContextFunction · 0.50
ExceptionClass · 0.50
isSystemStorageMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected