From fae50f66870c63ab5cfcedaf844a2a3138cf9bf8 Mon Sep 17 00:00:00 2001 From: "bingqing.lbq" Date: Fri, 19 Apr 2024 10:20:29 +0800 Subject: [PATCH 1/2] add a PhysicalPlanPrinter to avoid print all metadata in the physical plan Committed-by: bingqing.lbq from Dev container --- .../executor/ir/runtime/src/assembly.rs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/interactive_engine/executor/ir/runtime/src/assembly.rs b/interactive_engine/executor/ir/runtime/src/assembly.rs index 435e58ff1cf5..6a88a11e267c 100644 --- a/interactive_engine/executor/ir/runtime/src/assembly.rs +++ b/interactive_engine/executor/ir/runtime/src/assembly.rs @@ -811,7 +811,7 @@ impl JobAssembly for IRJobAssembly(&plan.plan)?; if log_enabled!(log::Level::Debug) && pegasus::get_current_worker().index == 0 { - debug!("{:#?}", physical_plan); + debug!("{:#?}", PhysicalPlanPrinter(&physical_plan)); } // input from a dummy record to trigger the computation let source = input.input_from(vec![Record::default()])?; @@ -853,3 +853,31 @@ fn decode(binary: &[u8]) -> FnGenResult { fn to_op_kind(opr: &pb::PhysicalOpr) -> FnGenResult { Ok(opr.try_into()?) } + +struct PhysicalPlanPrinter<'a>(&'a pb::PhysicalPlan); +struct PhysicalOprPrinter<'a>(&'a pb::PhysicalOpr); + +impl<'a> std::fmt::Debug for PhysicalPlanPrinter<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Plan") + .field( + "operations", + &self + .0 + .plan + .iter() + .map(PhysicalOprPrinter) + .collect::>(), + ) + .finish() + } +} + +impl<'a> std::fmt::Debug for PhysicalOprPrinter<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let opr = self.0; + f.debug_struct("PhysicalOpr") + .field("opr", &opr.opr) + .finish() + } +} From fa9e849343f2bf00e30d9d8b23b1efca4382f70b Mon Sep 17 00:00:00 2001 From: "bingqing.lbq" Date: Fri, 19 Apr 2024 10:53:06 +0800 Subject: [PATCH 2/2] avoid printing metadata in subplans in some operators Committed-by: bingqing.lbq from Dev container --- .../executor/ir/runtime/src/assembly.rs | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/interactive_engine/executor/ir/runtime/src/assembly.rs b/interactive_engine/executor/ir/runtime/src/assembly.rs index 6a88a11e267c..cd868a8516ae 100644 --- a/interactive_engine/executor/ir/runtime/src/assembly.rs +++ b/interactive_engine/executor/ir/runtime/src/assembly.rs @@ -876,8 +876,73 @@ impl<'a> std::fmt::Debug for PhysicalPlanPrinter<'a> { impl<'a> std::fmt::Debug for PhysicalOprPrinter<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let opr = self.0; - f.debug_struct("PhysicalOpr") - .field("opr", &opr.opr) - .finish() + if let Some(opr) = &opr.opr { + if let Some(op_kind) = &opr.op_kind { + match op_kind { + OpKind::Apply(apply) => f + .debug_struct("Apply") + .field("keys", &apply.keys) + .field( + "sub_plan", + &apply + .sub_plan + .as_ref() + .map(|plan| PhysicalPlanPrinter(plan)), + ) + .finish(), + OpKind::Join(join) => f + .debug_struct("Join") + .field( + "left_plan", + &join + .left_plan + .as_ref() + .map(|plan| PhysicalPlanPrinter(plan)), + ) + .field( + "right_plan", + &join + .right_plan + .as_ref() + .map(|plan| PhysicalPlanPrinter(plan)), + ) + .field("join_type", &join.join_kind) + .field("left_keys", &join.left_keys) + .field("right_keys", &join.right_keys) + .finish(), + OpKind::Union(union) => f + .debug_struct("Union") + .field( + "sub_plans", + &union + .sub_plans + .iter() + .map(|plan| PhysicalPlanPrinter(plan)) + .collect::>(), + ) + .finish(), + OpKind::Intersect(intersect) => f + .debug_struct("Intersect") + .field( + "sub_plans", + &intersect + .sub_plans + .iter() + .map(|plan| PhysicalPlanPrinter(plan)) + .collect::>(), + ) + .finish(), + _ => f + .debug_struct("PhysicalOpr") + .field("opr", op_kind) + .finish(), + } + } else { + f.debug_struct("Empty PhysicalOprOpKind") + .finish() + } + } else { + f.debug_struct("Empty PhysicalOpr").finish() + } } }