milenkovicm commented on code in PR #1309:
URL: 
https://github.com/apache/datafusion-ballista/pull/1309#discussion_r2336684925


##########
ballista/core/src/execution_plans/distributed_explain.rs:
##########
@@ -0,0 +1,236 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::any::Any;
+use std::fmt::{self, Display, Formatter};
+use std::sync::Arc;
+
+use arrow::{array::StringBuilder, datatypes::SchemaRef, 
record_batch::RecordBatch};
+
+use datafusion::common::display::{PlanType, StringifiedPlan};
+use datafusion::common::{internal_err, Result};
+use datafusion::execution::TaskContext;
+use datafusion::physical_expr::EquivalenceProperties;
+use datafusion::physical_plan::execution_plan::{Boundedness, EmissionType};
+use datafusion::physical_plan::stream::RecordBatchStreamAdapter;
+use datafusion::physical_plan::{
+    DisplayAs, DisplayFormatType, ExecutionPlan, Partitioning, PlanProperties,
+    SendableRecordBatchStream,
+};
+
+use log::trace;
+
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
+pub enum BallistaPlanType {
+    DataFusionPlanType(PlanType),
+    DistributedPlan,
+}
+
+impl Display for BallistaPlanType {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        match self {
+            BallistaPlanType::DataFusionPlanType(plan_type) => 
Display::fmt(plan_type, f),
+            BallistaPlanType::DistributedPlan => write!(f, "distributed_plan"),
+        }
+    }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
+pub struct BallistaStringifiedPlan {
+    pub plan_type: BallistaPlanType,
+    pub plan: Arc<String>,
+}
+
+impl BallistaStringifiedPlan {
+    pub fn new(plan_type: BallistaPlanType, plan: impl Into<String>) -> Self {
+        BallistaStringifiedPlan {
+            plan_type,
+            plan: Arc::new(plan.into()),
+        }
+    }
+
+    pub fn should_display(&self, verbose_mode: bool) -> bool {
+        match &self.plan_type {
+            BallistaPlanType::DataFusionPlanType(plan_type) => match plan_type 
{
+                PlanType::FinalLogicalPlan
+                | PlanType::FinalPhysicalPlan
+                | PlanType::PhysicalPlanError => true,
+                _ => verbose_mode,
+            },
+            BallistaPlanType::DistributedPlan => true,
+        }
+    }
+}
+
+impl From<&StringifiedPlan> for BallistaStringifiedPlan {
+    fn from(df_plan: &StringifiedPlan) -> Self {
+        Self {
+            plan_type: 
BallistaPlanType::DataFusionPlanType(df_plan.plan_type.clone()),
+            plan: Arc::clone(&df_plan.plan),
+        }
+    }
+}
+
+impl From<StringifiedPlan> for BallistaStringifiedPlan {
+    fn from(df_plan: StringifiedPlan) -> Self {
+        (&df_plan).into()
+    }
+}
+
+#[derive(Debug, Clone)]
+pub struct BallistaExplainExec {
+    schema: SchemaRef,
+    stringified_plans: Vec<BallistaStringifiedPlan>,
+    verbose: bool,
+    cache: PlanProperties,
+}
+
+impl BallistaExplainExec {

Review Comment:
   On the second thoughts, would this design with separate ExplainExec node 
help to implement `EXPLAIN ANALYSE` ?
   
   what do you think @danielhumanmod ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to