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

Method executeImpl

src/TableFunctions/TableFunctionLoop.cpp:120–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 }
119
120 StoragePtr TableFunctionLoop::executeImpl(
121 const ASTPtr & /*ast_function*/,
122 ContextPtr context,
123 const std::string & table_name,
124 ColumnsDescription cached_columns,
125 bool is_insert_query) const
126 {
127 StoragePtr storage;
128 if (!inner_table_function_ast)
129 {
130 String database_name = loop_database_name;
131 if (database_name.empty())
132 database_name = context->getCurrentDatabase();
133
134 auto database = DatabaseCatalog::instance().getDatabase(database_name);
135 storage = database->tryGetTable(loop_table_name, context);
136 if (!storage)
137 throw Exception(ErrorCodes::UNKNOWN_TABLE, "Table '{}' not found in database '{}'", loop_table_name, database_name);
138 context->checkAccess(AccessType::SELECT, database_name, loop_table_name);
139 }
140 else
141 {
142 auto inner_table_function = TableFunctionFactory::instance().get(inner_table_function_ast, context);
143 storage = inner_table_function->execute(
144 inner_table_function_ast,
145 context,
146 table_name,
147 std::move(cached_columns),
148 /*use_global_context=*/false,
149 /*is_insert_query=*/is_insert_query);
150 }
151 auto res = std::make_shared<StorageLoop>(
152 StorageID(getDatabaseName(), table_name),
153 storage,
154 inner_table_function_ast ? inner_table_function_ast->clone() : nullptr
155 );
156 res->startup();
157 return res;
158 }
159
160 void registerTableFunctionLoop(TableFunctionFactory & factory)
161 {

Callers

nothing calls this directly

Calls 11

getCurrentDatabaseMethod · 0.80
ExceptionClass · 0.50
StorageIDClass · 0.50
emptyMethod · 0.45
getDatabaseMethod · 0.45
tryGetTableMethod · 0.45
checkAccessMethod · 0.45
getMethod · 0.45
executeMethod · 0.45
cloneMethod · 0.45
startupMethod · 0.45

Tested by

no test coverage detected