Skip to content

Commit

Permalink
FOLLOWUP: remove more recursion in optimizer rules. (#4687)
Browse files Browse the repository at this point in the history
* remove more recursion in optimizer rule

* revert change push_down_filter

* cargo fmt
  • Loading branch information
jackwener authored Dec 22, 2022
1 parent 04d095d commit 77991a3
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 171 deletions.
12 changes: 6 additions & 6 deletions datafusion/optimizer/src/eliminate_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ mod tests {

use crate::test::*;

fn assert_eq(plan: &LogicalPlan, expected: &str) -> Result<()> {
fn assert_optimized_plan_equal(plan: &LogicalPlan, expected: &str) -> Result<()> {
assert_optimized_plan_eq(Arc::new(EliminateFilter::new()), plan, expected)
}

Expand All @@ -102,7 +102,7 @@ mod tests {

// No aggregate / scan / limit
let expected = "EmptyRelation";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -124,7 +124,7 @@ mod tests {
\n EmptyRelation\
\n Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b)]]\
\n TableScan: test";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -139,7 +139,7 @@ mod tests {

let expected = "Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b)]]\
\n TableScan: test";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -162,7 +162,7 @@ mod tests {
\n TableScan: test\
\n Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b)]]\
\n TableScan: test";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -185,6 +185,6 @@ mod tests {
// Filter is removed
let expected = "Projection: test.a\
\n EmptyRelation";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}
}
12 changes: 6 additions & 6 deletions datafusion/optimizer/src/eliminate_outer_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mod tests {
Operator::{And, Or},
};

fn assert_eq(plan: &LogicalPlan, expected: &str) -> Result<()> {
fn assert_optimized_plan_equal(plan: &LogicalPlan, expected: &str) -> Result<()> {
assert_optimized_plan_eq(Arc::new(EliminateOuterJoin::new()), plan, expected)
}

Expand All @@ -333,7 +333,7 @@ mod tests {
\n Left Join: t1.a = t2.a\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -356,7 +356,7 @@ mod tests {
\n Inner Join: t1.a = t2.a\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -383,7 +383,7 @@ mod tests {
\n Inner Join: t1.a = t2.a\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -410,7 +410,7 @@ mod tests {
\n Inner Join: t1.a = t2.a\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -437,6 +437,6 @@ mod tests {
\n Inner Join: t1.a = t2.a\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}
}
14 changes: 7 additions & 7 deletions datafusion/optimizer/src/filter_null_join_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod tests {
use datafusion_expr::logical_plan::table_scan;
use datafusion_expr::{col, lit, logical_plan::JoinType, LogicalPlanBuilder};

fn assert_eq(plan: &LogicalPlan, expected: &str) -> Result<()> {
fn assert_optimized_plan_equal(plan: &LogicalPlan, expected: &str) -> Result<()> {
assert_optimized_plan_eq(Arc::new(FilterNullJoinKeys {}), plan, expected)
}

Expand All @@ -127,7 +127,7 @@ mod tests {
\n Filter: t1.optional_id IS NOT NULL\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -138,7 +138,7 @@ mod tests {
\n Filter: t1.optional_id IS NOT NULL\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand Down Expand Up @@ -175,7 +175,7 @@ mod tests {
\n Filter: t1.optional_id IS NOT NULL\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -196,7 +196,7 @@ mod tests {
\n Filter: t1.optional_id + UInt32(1) IS NOT NULL\
\n TableScan: t1\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -217,7 +217,7 @@ mod tests {
\n TableScan: t1\
\n Filter: t2.optional_id + UInt32(1) IS NOT NULL\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

#[test]
Expand All @@ -240,7 +240,7 @@ mod tests {
\n TableScan: t1\
\n Filter: t2.optional_id + UInt32(1) IS NOT NULL\
\n TableScan: t2";
assert_eq(&plan, expected)
assert_optimized_plan_equal(&plan, expected)
}

fn build_plan(
Expand Down
Loading

0 comments on commit 77991a3

Please sign in to comment.