Skip to content

Commit

Permalink
revert4
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-toth committed Jan 12, 2024
1 parent 7a0f72f commit d88f21b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions datafusion/optimizer/src/decorrelate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<String, Expr>;

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<RewriteRecursion> {
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(_) => {
Expand All @@ -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<LogicalPlan> {
fn mutate(&mut self, plan: LogicalPlan) -> Result<LogicalPlan> {
let subquery_schema = plan.schema().clone();
match &plan {
LogicalPlan::Filter(plan_filter) => {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/decorrelate_predicate_subquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/scalar_subquery_to_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d88f21b

Please sign in to comment.