From 5ed0ad194acd40e0245fc8b88ccb12f721adb55a Mon Sep 17 00:00:00 2001 From: Winter Zhang Date: Thu, 28 Dec 2023 17:03:01 +0800 Subject: [PATCH] fix(executor): fix broken query profiling graph (#14183) * fix(executor): fix broken query profiling graph * fix(executor): fix broken query profiling graph --- .../service/src/pipelines/pipeline_builder.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/query/service/src/pipelines/pipeline_builder.rs b/src/query/service/src/pipelines/pipeline_builder.rs index cf320eb4a82ed..d37c8f90cb5fd 100644 --- a/src/query/service/src/pipelines/pipeline_builder.rs +++ b/src/query/service/src/pipelines/pipeline_builder.rs @@ -21,6 +21,7 @@ use databend_common_expression::DataField; use databend_common_expression::FunctionContext; use databend_common_pipeline_core::Pipeline; use databend_common_pipeline_core::PlanScope; +use databend_common_pipeline_core::PlanScopeGuard; use databend_common_profile::SharedProcessorProfiles; use databend_common_settings::Settings; use databend_common_sql::executor::PhysicalPlan; @@ -101,9 +102,18 @@ impl PipelineBuilder { }) } + pub(crate) fn add_plan_scope(&mut self, plan: &PhysicalPlan) -> Option { + match plan { + PhysicalPlan::EvalScalar(v) if v.exprs.is_empty() => None, + _ => { + let scope = PlanScope::create(plan.get_id(), plan.name()); + Some(self.main_pipeline.add_plan_scope(scope)) + } + } + } + pub(crate) fn build_pipeline(&mut self, plan: &PhysicalPlan) -> Result<()> { - let scope = PlanScope::create(plan.get_id(), plan.name()); - let _guard = self.main_pipeline.add_plan_scope(scope); + let _guard = self.add_plan_scope(plan); match plan { PhysicalPlan::TableScan(scan) => self.build_table_scan(scan), PhysicalPlan::CteScan(scan) => self.build_cte_scan(scan),