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

Method initializePipeline

src/QueryPlan/ReadFromMergeTree.cpp:1386–1606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1384}
1385
1386void ReadFromMergeTree::initializePipeline(QueryPipeline & pipeline, const BuildQueryPipelineSettings &)
1387{
1388 auto result = getAnalysisResult();
1389 LOG_DEBUG(
1390 log,
1391 "Selected {}/{} parts by partition key, {} parts by primary key, {}/{} marks by primary key, {} marks to read from {} ranges",
1392 result.parts_before_pk,
1393 result.total_parts,
1394 result.selected_parts,
1395 result.selected_marks_pk,
1396 result.total_marks_pk,
1397 result.selected_marks,
1398 result.selected_ranges);
1399
1400 if (context->getSettingsRef().report_segment_profiles)
1401 fillRuntimeAttributeDescriptions(result);
1402
1403 ProfileEvents::increment(ProfileEvents::SelectedParts, result.selected_parts);
1404 ProfileEvents::increment(ProfileEvents::SelectedRanges, result.selected_ranges);
1405 ProfileEvents::increment(ProfileEvents::SelectedMarks, result.selected_marks);
1406
1407 auto query_id_holder = MergeTreeDataSelectExecutor::checkLimits(data, result.parts_with_ranges, context);
1408
1409 if (result.part_cache_holder)
1410 pipeline.addCacheHolder(std::move(result.part_cache_holder));
1411
1412 if (result.parts_with_ranges.empty())
1413 {
1414 pipeline.init(Pipe(std::make_shared<NullSource>(getOutputStream().header)));
1415 return;
1416 }
1417
1418 // extract selected_parts_vector before result.parts_with_ranges be moved
1419 auto selected_parts_vector = getSelectedPartsVector(result);
1420
1421 /// Projection, that needed to drop columns, which have appeared by execution
1422 /// of some extra expressions, and to allow execute the same expressions later.
1423 /// NOTE: It may lead to double computation of expressions.
1424 ActionsDAGPtr result_projection;
1425
1426 Names column_names_to_read = std::move(result.column_names_to_read);
1427 const auto & select = query_info.query->as<ASTSelectQuery &>();
1428 if (!select.final() && result.sampling.use_sampling && !context->getSettingsRef().enable_sample_by_range
1429 && !context->getSettingsRef().enable_deterministic_sample_by_range)
1430 {
1431 /// Add columns needed for `sample_by_ast` to `column_names_to_read`.
1432 /// Skip this if final was used, because such columns were already added from PK.
1433 std::vector<String> add_columns = result.sampling.filter_expression->getRequiredColumns().getNames();
1434 column_names_to_read.insert(column_names_to_read.end(), add_columns.begin(), add_columns.end());
1435 std::sort(column_names_to_read.begin(), column_names_to_read.end());
1436 column_names_to_read.erase(std::unique(column_names_to_read.begin(), column_names_to_read.end()),
1437 column_names_to_read.end());
1438 }
1439
1440 const auto & input_order_info = query_info.input_order_info
1441 ? query_info.input_order_info
1442 : (query_info.projection ? query_info.projection->input_order_info : nullptr);
1443

Callers

nothing calls this directly

Calls 15

getSelectedPartsVectorFunction · 0.85
sortFunction · 0.85
TreeRewriterClass · 0.85
canReadInPartitionOrderFunction · 0.85
extractMapColumnKeysFunction · 0.85
isCompatibleHeaderFunction · 0.85
finalMethod · 0.80
getAllPhysicalMethod · 0.80
getActionsDAGMethod · 0.80
createColumnConstMethod · 0.80
addQueryIdHolderMethod · 0.80

Tested by

no test coverage detected