Skip to content

Commit 3023d88

Browse files
committed
fix tests
1 parent 7b6f778 commit 3023d88

File tree

2 files changed

+15
-69
lines changed
  • datafusion/core/tests/physical_optimizer/filter_pushdown

2 files changed

+15
-69
lines changed

datafusion/core/tests/physical_optimizer/filter_pushdown/mod.rs

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,6 @@ async fn test_hashjoin_dynamic_filter_pushdown() {
934934
stream.next().await.unwrap().unwrap();
935935

936936
// Now check what our filter looks like
937-
// `probe_keys=2` indicates the dynamic filter was derived from two probe-side
938-
// join key columns (here `a` and `b`). It verifies the optimizer generated a
939-
// probe-side predicate that constrains both join keys from the small build side.
940937
insta::assert_snapshot!(
941938
format!("{}", format_plan_for_test(&plan)),
942939
@r"
@@ -1245,8 +1242,7 @@ async fn test_hashjoin_dynamic_filter_pushdown_high_cardinality() {
12451242
.expect("optimizer should finish in time")
12461243
.unwrap();
12471244
let formatted = format_plan_for_test(&plan);
1248-
// Programmatic check: ensure some child received a dynamic filter for Inner join
1249-
assert_dynamic_filter_location_plan(&plan, &JoinType::Inner);
1245+
assert_contains!(&formatted, "DynamicFilterPhysicalExpr");
12501246

12511247
assert_contains!(&formatted, "probe_keys=0");
12521248

@@ -1348,63 +1344,6 @@ fn assert_dynamic_filter_location(formatted: &str, join_type: &JoinType) {
13481344
}
13491345
}
13501346

1351-
/// Programmatic check: inspect the `HashJoinExec` children and verify which
1352-
/// side received a pushed predicate in the underlying `TestSource`.
1353-
fn assert_dynamic_filter_location_plan(
1354-
plan: &Arc<dyn ExecutionPlan>,
1355-
join_type: &JoinType,
1356-
) {
1357-
// Find top-level HashJoinExec
1358-
let join = plan
1359-
.as_any()
1360-
.downcast_ref::<HashJoinExec>()
1361-
.expect("expected HashJoinExec");
1362-
1363-
// Helper to check whether a child has a pushed predicate
1364-
let child_has_predicate = |child: &Arc<dyn ExecutionPlan>| -> bool {
1365-
if let Some(data_src) = child
1366-
.as_any()
1367-
.downcast_ref::<datafusion::datasource::source::DataSourceExec>(
1368-
) {
1369-
if let Some((_, test_source)) =
1370-
data_src.downcast_to_file_source::<util::TestSource>()
1371-
{
1372-
return test_source.predicate().is_some();
1373-
}
1374-
}
1375-
false
1376-
};
1377-
1378-
match join_type {
1379-
JoinType::Left | JoinType::LeftSemi | JoinType::LeftAnti | JoinType::LeftMark => {
1380-
// For left-type joins the right side (probe) should receive the dynamic filter
1381-
assert!(
1382-
child_has_predicate(&join.right),
1383-
"expected predicate on right child"
1384-
);
1385-
assert!(
1386-
!child_has_predicate(&join.left),
1387-
"expected no predicate on left child"
1388-
);
1389-
}
1390-
JoinType::Right
1391-
| JoinType::RightSemi
1392-
| JoinType::RightAnti
1393-
| JoinType::RightMark => {
1394-
// For right-type joins the left side should receive the dynamic filter
1395-
assert!(
1396-
child_has_predicate(&join.left),
1397-
"expected predicate on left child"
1398-
);
1399-
assert!(
1400-
!child_has_predicate(&join.right),
1401-
"expected no predicate on right child"
1402-
);
1403-
}
1404-
_ => unreachable!(),
1405-
}
1406-
}
1407-
14081347
#[rstest(
14091348
join_type,
14101349
case::inner(JoinType::Inner),
@@ -1469,7 +1408,7 @@ async fn test_hashjoin_outer_dynamic_filter_pushdown(join_type: JoinType) {
14691408
.optimize(plan, &config)
14701409
.unwrap();
14711410
let formatted = format_plan_for_test(&plan);
1472-
assert_dynamic_filter_location_plan(&plan, &join_type);
1411+
assert_dynamic_filter_location(&formatted, &join_type);
14731412
assert_contains!(&formatted, "probe_keys=0");
14741413
}
14751414

@@ -1503,8 +1442,14 @@ async fn test_hashjoin_left_dynamic_filter_pushdown_collect_left() {
15031442
.optimize(plan, &config)
15041443
.unwrap();
15051444
let formatted = format_plan_for_test(&plan);
1506-
// Programmatic check: verify the dynamic filter was pushed to the expected side
1507-
assert_dynamic_filter_location_plan(&plan, &JoinType::Left);
1445+
assert_contains!(
1446+
&formatted,
1447+
"DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, e], file_type=test, pushdown_supported=true, predicate=DynamicFilterPhysicalExpr"
1448+
);
1449+
assert_contains!(
1450+
&formatted,
1451+
"DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=<none>"
1452+
);
15081453
assert_contains!(&formatted, "probe_keys=0");
15091454
}
15101455

@@ -1524,7 +1469,7 @@ async fn test_hashjoin_semi_dynamic_filter_pushdown(join_type: JoinType) {
15241469
.optimize(plan, &config)
15251470
.unwrap();
15261471
let formatted = format_plan_for_test(&plan);
1527-
assert_dynamic_filter_location_plan(&plan, &join_type);
1472+
assert_dynamic_filter_location(&formatted, &join_type);
15281473
assert_contains!(&formatted, "probe_keys=0");
15291474
}
15301475

@@ -1544,7 +1489,7 @@ async fn test_hashjoin_anti_dynamic_filter_pushdown(join_type: JoinType) {
15441489
.optimize(plan, &config)
15451490
.unwrap();
15461491
let formatted = format_plan_for_test(&plan);
1547-
assert_dynamic_filter_location_plan(&plan, &join_type);
1492+
assert_dynamic_filter_location(&formatted, &join_type);
15481493
assert_contains!(&formatted, "probe_keys=0");
15491494
}
15501495

@@ -1564,7 +1509,7 @@ async fn test_hashjoin_mark_dynamic_filter_pushdown(join_type: JoinType) {
15641509
.optimize(plan, &config)
15651510
.unwrap();
15661511
let formatted = format_plan_for_test(&plan);
1567-
assert_dynamic_filter_location_plan(&plan, &join_type);
1512+
assert_dynamic_filter_location(&formatted, &join_type);
15681513
assert_contains!(&formatted, "probe_keys=0");
15691514
}
15701515

datafusion/core/tests/physical_optimizer/filter_pushdown/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl FileSource for TestSource {
152152
}
153153

154154
fn as_any(&self) -> &dyn Any {
155-
todo!("should not be called")
155+
// Allow downcasting a FileSource to the concrete TestSource in tests.
156+
self
156157
}
157158

158159
fn with_batch_size(&self, batch_size: usize) -> Arc<dyn FileSource> {

0 commit comments

Comments
 (0)