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

Method getSampleBlock

src/Interpreters/InterpreterSelectWithUnionQuery.cpp:276–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274InterpreterSelectWithUnionQuery::~InterpreterSelectWithUnionQuery() = default;
275
276SharedHeader InterpreterSelectWithUnionQuery::getSampleBlock(const ASTPtr & query_ptr_, ContextPtr context_, bool is_subquery, bool is_create_parameterized_view)
277{
278 if (!context_->hasQueryContext())
279 {
280 SelectQueryOptions options;
281 if (is_subquery)
282 options = options.subquery();
283 if (is_create_parameterized_view)
284 options = options.createParameterizedView();
285 return InterpreterSelectWithUnionQuery(query_ptr_, context_, std::move(options.analyze())).getSampleBlock();
286 }
287
288 /// Using query string because query_ptr changes for every internal SELECT
289 auto key = query_ptr_->formatWithSecretsOneLine();
290 {
291 auto [cache, lock] = context_->getSampleBlockCache();
292 if (cache->contains(key))
293 return cache->at(key);
294 }
295
296 SelectQueryOptions options;
297 if (is_subquery)
298 options = options.subquery();
299 if (is_create_parameterized_view)
300 options = options.createParameterizedView();
301
302 auto sample_block = InterpreterSelectWithUnionQuery(query_ptr_, context_, std::move(options.analyze())).getSampleBlock();
303 auto [cache, lock] = context_->getSampleBlockCache();
304 return (*cache)[key] = sample_block;
305}
306
307
308void InterpreterSelectWithUnionQuery::buildQueryPlan(QueryPlan & query_plan)

Calls 9

hasQueryContextMethod · 0.80
subqueryMethod · 0.80
getSampleBlockCacheMethod · 0.80
analyzeMethod · 0.45
containsMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected