mingmwang commented on a change in pull request #2029:
URL: https://github.com/apache/arrow-datafusion/pull/2029#discussion_r830713749



##########
File path: datafusion/src/execution/context.rs
##########
@@ -667,34 +635,15 @@ impl SessionContext {
 
     /// Optimizes the logical plan by applying optimizer rules.
     pub fn optimize(&self, plan: &LogicalPlan) -> Result<LogicalPlan> {
-        if let LogicalPlan::Explain(e) = plan {
-            let mut stringified_plans = e.stringified_plans.clone();
-
-            // optimize the child plan, capturing the output of each optimizer
-            let plan =
-                self.optimize_internal(e.plan.as_ref(), |optimized_plan, 
optimizer| {
-                    let optimizer_name = optimizer.name().to_string();
-                    let plan_type = PlanType::OptimizedLogicalPlan { 
optimizer_name };
-                    
stringified_plans.push(optimized_plan.to_stringified(plan_type));
-                })?;
-
-            Ok(LogicalPlan::Explain(Explain {
-                verbose: e.verbose,
-                plan: Arc::new(plan),
-                stringified_plans,
-                schema: e.schema.clone(),
-            }))
-        } else {
-            self.optimize_internal(plan, |_, _| {})
-        }
+        self.state.lock().optimize(plan)

Review comment:
       How about a RW lock ?




-- 
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]


Reply via email to