alamb commented on a change in pull request #2029:
URL: https://github.com/apache/arrow-datafusion/pull/2029#discussion_r831435104
##########
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:
> BTW, I didn't modify the lock related behavior, originally the
optimize_internal() method was guarded by the same state lock and serialize the
optimization rules running too.
Yeah, it is somewhat of a mess
##########
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:
> BTW, I didn't modify the lock related behavior, originally the
optimize_internal() method was guarded by the same state lock and serialize the
optimization rules running too.
Yeah, it is somewhat of a mess -- it will be nice to clean this up in a
subsequent PR
--
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]