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

Method getSampleBlock

src/Interpreters/InterpreterInsertQuery.cpp:201–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201Block InterpreterInsertQuery::getSampleBlock(
202 const ASTInsertQuery & query,
203 const StoragePtr & table,
204 const StorageMetadataPtr & metadata_snapshot,
205 ContextPtr context_,
206 bool no_destination,
207 bool allow_materialized)
208{
209 /// If the query does not include information about columns
210 if (!query.columns)
211 {
212 if (auto * window_view = dynamic_cast<StorageWindowView *>(table.get()))
213 return window_view->getInputHeader();
214 if (no_destination)
215 return metadata_snapshot->getSampleBlockWithVirtuals(VirtualsKind::All, VirtualsMaterializationPlace::All);
216 return metadata_snapshot->getSampleBlockNonMaterialized();
217 }
218
219 /// Form the block based on the column names from the query
220 const auto columns_ast = processColumnTransformers(context_->getCurrentDatabase(), table, metadata_snapshot, query.columns);
221 Names names;
222 names.reserve(columns_ast->children.size());
223 for (const auto & identifier : columns_ast->children)
224 {
225 std::string current_name = identifier->getColumnName();
226 names.emplace_back(std::move(current_name));
227 }
228
229 return getSampleBlock(names, table, metadata_snapshot, no_destination, allow_materialized);
230}
231
232Block InterpreterInsertQuery::getSampleBlock(
233 const Names & names,

Callers

nothing calls this directly

Calls 15

getInputHeaderMethod · 0.80
getCurrentDatabaseMethod · 0.80
getByNameMethod · 0.80
getSampleBlockFunction · 0.70
ExceptionClass · 0.70
getMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected