Merge pull request #68954 from ClickHouse/processors_profile_log_plan_step_name

Add plan_step_name and plan_step_description columns to system.processors_profile_log
This commit is contained in:
Alexander Gololobov 2024-09-03 14:53:08 +00:00 committed by GitHub
commit e94a2875de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 5 deletions

View File

@ -30,6 +30,8 @@ ColumnsDescription ProcessorProfileLogElement::getColumnsDescription()
{"id", std::make_shared<DataTypeUInt64>(), "ID of processor."},
{"parent_ids", std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>()), "Parent processors IDs."},
{"plan_step", std::make_shared<DataTypeUInt64>(), "ID of the query plan step which created this processor. The value is zero if the processor was not added from any step."},
{"plan_step_name", std::make_shared<DataTypeString>(), "Name of the query plan step which created this processor. The value is empty if the processor was not added from any step."},
{"plan_step_description", std::make_shared<DataTypeString>(), "Description of the query plan step which created this processor. The value is empty if the processor was not added from any step."},
{"plan_group", std::make_shared<DataTypeUInt64>(), "Group of the processor if it was created by query plan step. A group is a logical partitioning of processors added from the same query plan step. Group is used only for beautifying the result of EXPLAIN PIPELINE result."},
{"initial_query_id", std::make_shared<DataTypeString>(), "ID of the initial query (for distributed query execution)."},
@ -64,6 +66,8 @@ void ProcessorProfileLogElement::appendToBlock(MutableColumns & columns) const
}
columns[i++]->insert(plan_step);
columns[i++]->insert(plan_step_name);
columns[i++]->insert(plan_step_description);
columns[i++]->insert(plan_group);
columns[i++]->insertData(initial_query_id.data(), initial_query_id.size());
columns[i++]->insertData(query_id.data(), query_id.size());

View File

@ -19,6 +19,8 @@ struct ProcessorProfileLogElement
UInt64 plan_step{};
UInt64 plan_group{};
String plan_step_name;
String plan_step_description;
String initial_query_id;
String query_id;

View File

@ -478,6 +478,8 @@ void logQueryFinish(
processor_elem.parent_ids = std::move(parents);
processor_elem.plan_step = reinterpret_cast<std::uintptr_t>(processor->getQueryPlanStep());
processor_elem.plan_step_name = processor->getPlanStepName();
processor_elem.plan_step_description = processor->getPlanStepDescription();
processor_elem.plan_group = processor->getQueryPlanStepGroup();
processor_elem.processor_name = processor->getName();

View File

@ -1,5 +1,6 @@
#include <iostream>
#include <Processors/IProcessor.h>
#include <Processors/QueryPlan/IQueryPlanStep.h>
#include <Common/logger_useful.h>
#include <IO/WriteHelpers.h>
@ -9,6 +10,17 @@
namespace DB
{
void IProcessor::setQueryPlanStep(IQueryPlanStep * step, size_t group)
{
query_plan_step = step;
query_plan_step_group = group;
if (step)
{
plan_step_name = step->getName();
plan_step_description = step->getStepDescription();
}
}
void IProcessor::cancel() noexcept
{

View File

@ -311,14 +311,12 @@ public:
constexpr static size_t NO_STREAM = std::numeric_limits<size_t>::max();
/// Step of QueryPlan from which processor was created.
void setQueryPlanStep(IQueryPlanStep * step, size_t group = 0)
{
query_plan_step = step;
query_plan_step_group = group;
}
void setQueryPlanStep(IQueryPlanStep * step, size_t group = 0);
IQueryPlanStep * getQueryPlanStep() const { return query_plan_step; }
size_t getQueryPlanStepGroup() const { return query_plan_step_group; }
const String & getPlanStepName() const { return plan_step_name; }
const String & getPlanStepDescription() const { return plan_step_description; }
uint64_t getElapsedNs() const { return elapsed_ns; }
uint64_t getInputWaitElapsedNs() const { return input_wait_elapsed_ns; }
@ -410,6 +408,8 @@ private:
IQueryPlanStep * query_plan_step = nullptr;
size_t query_plan_step_group = 0;
String plan_step_name;
String plan_step_description;
};