From d88f21b7765f8502f8eb254cb6b7c41396ee83e1 Mon Sep 17 00:00:00 2001 From: Peter Toth Date: Fri, 12 Jan 2024 14:38:58 +0100 Subject: [PATCH] revert4 --- datafusion/optimizer/src/decorrelate.rs | 24 +++++++++---------- .../src/decorrelate_predicate_subquery.rs | 2 +- .../optimizer/src/scalar_subquery_to_join.rs | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/datafusion/optimizer/src/decorrelate.rs b/datafusion/optimizer/src/decorrelate.rs index 903d2e93ded9c..e86f8ec6b22ff 100644 --- a/datafusion/optimizer/src/decorrelate.rs +++ b/datafusion/optimizer/src/decorrelate.rs @@ -17,7 +17,7 @@ use crate::simplify_expressions::{ExprSimplifier, SimplifyContext}; use crate::utils::collect_subquery_cols; -use datafusion_common::tree_node::{TreeNode, TreeNodeRecursion, TreeNodeRewriter}; +use datafusion_common::tree_node::{RewriteRecursion, TreeNode, TreeNodeRewriterOld}; use datafusion_common::{plan_err, Result}; use datafusion_common::{Column, DFSchemaRef, DataFusionError, ScalarValue}; use datafusion_expr::expr::{AggregateFunctionDefinition, Alias}; @@ -53,20 +53,20 @@ pub const UN_MATCHED_ROW_INDICATOR: &str = "__always_true"; /// Mapping from expr display name to its evaluation result on empty record batch (for example: 'count(*)' is 'ScalarValue(0)', 'count(*) + 2' is 'ScalarValue(2)') pub type ExprResultMap = HashMap; -impl TreeNodeRewriter for PullUpCorrelatedExpr { - type Node = LogicalPlan; +impl TreeNodeRewriterOld for PullUpCorrelatedExpr { + type N = LogicalPlan; - fn f_down(&mut self, plan: LogicalPlan) -> Result<(LogicalPlan, TreeNodeRecursion)> { + fn pre_visit(&mut self, plan: &LogicalPlan) -> Result { match plan { - LogicalPlan::Filter(_) => Ok((plan, TreeNodeRecursion::Continue)), + LogicalPlan::Filter(_) => Ok(RewriteRecursion::Continue), LogicalPlan::Union(_) | LogicalPlan::Sort(_) | LogicalPlan::Extension(_) => { let plan_hold_outer = !plan.all_out_ref_exprs().is_empty(); if plan_hold_outer { // the unsupported case self.can_pull_up = false; - Ok((plan, TreeNodeRecursion::Skip)) + Ok(RewriteRecursion::Stop) } else { - Ok((plan, TreeNodeRecursion::Continue)) + Ok(RewriteRecursion::Continue) } } LogicalPlan::Limit(_) => { @@ -75,21 +75,21 @@ impl TreeNodeRewriter for PullUpCorrelatedExpr { (false, true) => { // the unsupported case self.can_pull_up = false; - Ok((plan, TreeNodeRecursion::Skip)) + Ok(RewriteRecursion::Stop) } - _ => Ok((plan, TreeNodeRecursion::Continue)), + _ => Ok(RewriteRecursion::Continue), } } _ if plan.expressions().iter().any(|expr| expr.contains_outer()) => { // the unsupported cases, the plan expressions contain out reference columns(like window expressions) self.can_pull_up = false; - Ok((plan, TreeNodeRecursion::Skip)) + Ok(RewriteRecursion::Stop) } - _ => Ok((plan, TreeNodeRecursion::Continue)), + _ => Ok(RewriteRecursion::Continue), } } - fn f_up(&mut self, plan: LogicalPlan) -> Result { + fn mutate(&mut self, plan: LogicalPlan) -> Result { let subquery_schema = plan.schema().clone(); match &plan { LogicalPlan::Filter(plan_filter) => { diff --git a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs index 450336376a239..1e0a3d600095a 100644 --- a/datafusion/optimizer/src/decorrelate_predicate_subquery.rs +++ b/datafusion/optimizer/src/decorrelate_predicate_subquery.rs @@ -228,7 +228,7 @@ fn build_join( collected_count_expr_map: Default::default(), pull_up_having_expr: None, }; - let new_plan = subquery.clone().rewrite(&mut pull_up)?; + let new_plan = subquery.clone().rewrite_old(&mut pull_up)?; if !pull_up.can_pull_up { return Ok(None); } diff --git a/datafusion/optimizer/src/scalar_subquery_to_join.rs b/datafusion/optimizer/src/scalar_subquery_to_join.rs index 6306af303000f..3543f98b1dfb9 100644 --- a/datafusion/optimizer/src/scalar_subquery_to_join.rs +++ b/datafusion/optimizer/src/scalar_subquery_to_join.rs @@ -280,7 +280,7 @@ fn build_join( collected_count_expr_map: Default::default(), pull_up_having_expr: None, }; - let new_plan = subquery_plan.clone().rewrite(&mut pull_up)?; + let new_plan = subquery_plan.clone().rewrite_old(&mut pull_up)?; if !pull_up.can_pull_up { return Ok(None); }