Skip to content

Commit

Permalink
Update tests 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Sep 28, 2023
1 parent a44f638 commit 095042f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 57 deletions.
88 changes: 32 additions & 56 deletions datafusion/optimizer/src/push_down_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,7 @@ mod tests {
// filter is before projection
let expected = "\
Projection: test.a, test.b\
\n Filter: test.a = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand All @@ -972,9 +971,7 @@ mod tests {
let plan = LogicalPlanBuilder::from(table_scan)
.filter(lit(0i64).eq(lit(1i64)))?
.build()?;
let expected = "\
Filter: Int64(0) = Int64(1)\
\n TableScan: test";
let expected = "TableScan: test, full_filters=[Int64(0) = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand All @@ -990,8 +987,7 @@ mod tests {
let expected = "\
Projection: test.c, test.b\
\n Projection: test.a, test.b, test.c\
\n Filter: test.a = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand All @@ -1005,8 +1001,7 @@ mod tests {
// filter of key aggregation is commutative
let expected = "\
Aggregate: groupBy=[[test.a]], aggr=[[SUM(test.b) AS total_salary]]\
\n Filter: test.a > Int64(10)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a > Int64(10)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1063,7 +1058,7 @@ mod tests {
let expected = "\
Projection: test.a AS b, test.c\
\n Filter: test.a = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1107,8 +1102,7 @@ mod tests {
// filter is before projection
let expected = "\
Projection: test.a * Int32(2) + test.c AS b, test.c\
\n Filter: test.a * Int32(2) + test.c = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a * Int32(2) + test.c = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1140,8 +1134,7 @@ mod tests {
let expected = "\
Projection: b * Int32(3) AS a, test.c\
\n Projection: test.a * Int32(2) + test.c AS b, test.c\
\n Filter: (test.a * Int32(2) + test.c) * Int32(3) = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[(test.a * Int32(2) + test.c) * Int32(3) = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1222,8 +1215,7 @@ mod tests {
let expected = "\
Filter: test.c = Int64(2)\
\n NoopPlan\
\n Filter: test.a = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)?;

let custom_plan = LogicalPlan::Extension(Extension {
Expand Down Expand Up @@ -1367,10 +1359,8 @@ mod tests {
.build()?;
// filter appears below Union
let expected = "Union\
\n Filter: test.a = Int64(1)\
\n TableScan: test\
\n Filter: test2.a = Int64(1)\
\n TableScan: test2";
\n TableScan: test, full_filters=[test.a = Int64(1)]\
\n TableScan: test2, full_filters=[test2.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand All @@ -1390,12 +1380,10 @@ mod tests {
// filter appears below Union
let expected = "Union\n SubqueryAlias: test2\
\n Projection: test.a AS b\
\n Filter: test.a = Int64(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a = Int64(1)]\
\n SubqueryAlias: test2\
\n Projection: test.a AS b\
\n Filter: test.a = Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a = Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1489,8 +1477,7 @@ mod tests {
\n Filter: test.a >= Int64(1)\
\n Limit: skip=0, fetch=1\
\n Projection: test.a\
\n Filter: test.a <= Int64(1)\
\n TableScan: test";
\n TableScan: test, full_filters=[test.a <= Int64(1)]";

assert_optimized_plan_eq(&plan, expected)
}
Expand Down Expand Up @@ -1544,6 +1531,10 @@ mod tests {
// not part of the test
assert_eq!(format!("{plan:?}"), expected);

let expected = "\
TestUserDefined\
\n TableScan: test, full_filters=[test.a <= Int64(1)]";

assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1579,11 +1570,9 @@ mod tests {
// filter sent to side before the join
let expected = "\
Inner Join: test.a = test2.a\
\n Filter: test.a <= Int64(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a <= Int64(1)]\
\n Projection: test2.a\
\n Filter: test2.a <= Int64(1)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.a <= Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1618,11 +1607,9 @@ mod tests {
// filter sent to side before the join
let expected = "\
Inner Join: Using test.a = test2.a\
\n Filter: test.a <= Int64(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a <= Int64(1)]\
\n Projection: test2.a\
\n Filter: test2.a <= Int64(1)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.a <= Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1704,8 +1691,7 @@ mod tests {
let expected = "\
Inner Join: test.a = test2.a\
\n Projection: test.a, test.b\
\n Filter: test.b <= Int64(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.b <= Int64(1)]\
\n Projection: test2.a, test2.c\
\n TableScan: test2";
assert_optimized_plan_eq(&plan, expected)
Expand Down Expand Up @@ -1820,8 +1806,7 @@ mod tests {
// filter sent to left side of the join, not the right
let expected = "\
Left Join: Using test.a = test2.a\
\n Filter: test.a <= Int64(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a <= Int64(1)]\
\n Projection: test2.a\
\n TableScan: test2";
assert_optimized_plan_eq(&plan, expected)
Expand Down Expand Up @@ -1861,8 +1846,7 @@ mod tests {
Right Join: Using test.a = test2.a\
\n TableScan: test\
\n Projection: test2.a\
\n Filter: test2.a <= Int64(1)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.a <= Int64(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1903,11 +1887,9 @@ mod tests {
let expected = "\
Inner Join: test.a = test2.a Filter: test.b < test2.b\
\n Projection: test.a, test.b, test.c\
\n Filter: test.c > UInt32(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.c > UInt32(1)]\
\n Projection: test2.a, test2.b, test2.c\
\n Filter: test2.c > UInt32(4)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.c > UInt32(4)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1947,11 +1929,9 @@ mod tests {
let expected = "\
Inner Join: test.a = test2.a\
\n Projection: test.a, test.b, test.c\
\n Filter: test.b > UInt32(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.b > UInt32(1)]\
\n Projection: test2.a, test2.b, test2.c\
\n Filter: test2.c > UInt32(4)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.c > UInt32(4)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -1989,11 +1969,9 @@ mod tests {
let expected = "\
Inner Join: test.a = test2.b\
\n Projection: test.a\
\n Filter: test.a > UInt32(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a > UInt32(1)]\
\n Projection: test2.b\
\n Filter: test2.b > UInt32(1)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.b > UInt32(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down Expand Up @@ -2406,11 +2384,9 @@ Projection: a, b
let expected = "\
Inner Join: c = d\
\n Projection: test.a AS c\
\n Filter: test.a > UInt32(1)\
\n TableScan: test\
\n TableScan: test, full_filters=[test.a > UInt32(1)]\
\n Projection: test2.b AS d\
\n Filter: test2.b > UInt32(1)\
\n TableScan: test2";
\n TableScan: test2, full_filters=[test2.b > UInt32(1)]";
assert_optimized_plan_eq(&plan, expected)
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/push_down_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ mod tests {
let table_scan = table_scan_with_filters(
Some("test"),
&schema,
None,
Some(vec![2]),
vec![col("b").eq(lit(1))],
)?
.build()?;
Expand Down

0 comments on commit 095042f

Please sign in to comment.