Skip to content

Commit 833d02b

Browse files
committed
First draft of adding tests for empty join filters
1 parent 8b19ce8 commit 833d02b

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

datafusion/expr/src/logical_plan/builder.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,40 @@ mod tests {
21952195
);
21962196
}
21972197

2198+
#[test]
2199+
fn plan_builder_join_cannot_accidentally_create_cross_join() {
2200+
let schema = employee_schema();
2201+
let lhs = LogicalPlanBuilder::scan("lhs", table_source(&schema), projection);
2202+
let rhs = LogicalPlanBuilder::scan("rhs", table_source(&schema), projection)
2203+
.build()
2204+
.unwrap();
2205+
2206+
let join = lhs
2207+
.join(JoinType::Inner, &rhs, (vec![], vec![]), None)
2208+
.unwrap_err();
2209+
2210+
assert_eq!(
2211+
err.strip_backtrace(),
2212+
"Error during planning: table_name cannot be empty"
2213+
);
2214+
}
2215+
2216+
#[test]
2217+
fn plan_builder_join_no_filter_is_ok_for_non_inner_join() {
2218+
let schema = employee_schema();
2219+
let lhs = LogicalPlanBuilder::scan("lhs", table_source(&schema), projection);
2220+
let rhs = LogicalPlanBuilder::scan("rhs", table_source(&schema), projection)
2221+
.build()
2222+
.unwrap();
2223+
2224+
let join = lhs.join(JoinType::Left, &rhs, (vec![], vec![]), None);
2225+
2226+
assert!(
2227+
join.is_ok(),
2228+
"A non-inner join without a filter should be allowed"
2229+
);
2230+
}
2231+
21982232
#[test]
21992233
fn plan_builder_sort() -> Result<()> {
22002234
let plan =

0 commit comments

Comments
 (0)