Skip to content

Commit ca2ba67

Browse files
committed
Add focused tests for cross join and scalar subquery
Introduce two tests to identify the promotion path behind the regression. The tests validate that the cross join is represented as Inner Join with no join filters and that a scalar subquery condition is considered a candidate for join evaluation. These changes help pinpoint the branch in push_down_all_join affecting the transformation of the Cross Join and Filter into Inner Join.
1 parent 7e5d9d2 commit ca2ba67

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,33 @@ mod tests {
24712471
)
24722472
}
24732473

2474+
#[test]
2475+
fn cross_join_builder_uses_inner_join_with_no_join_keys() -> Result<()> {
2476+
let plan = LogicalPlanBuilder::from(test_table_scan()?)
2477+
.cross_join(test_table_scan_with_name("test1")?)?
2478+
.build()?;
2479+
2480+
let LogicalPlan::Join(join) = plan else {
2481+
panic!("expected join plan");
2482+
};
2483+
2484+
assert_eq!(join.join_type, JoinType::Inner);
2485+
assert!(join.on.is_empty());
2486+
assert!(join.filter.is_none());
2487+
2488+
Ok(())
2489+
}
2490+
2491+
#[test]
2492+
fn scalar_subquery_cross_join_filter_is_treated_as_join_condition_candidate(
2493+
) -> Result<()> {
2494+
let predicate = col("s.acctbal").gt(col("__scalar_sq_1.avg_acctbal"));
2495+
2496+
assert!(can_evaluate_as_join_condition(&predicate)?);
2497+
2498+
Ok(())
2499+
}
2500+
24742501
/// verifies that filters with the same columns are correctly placed
24752502
#[test]
24762503
fn filter_2_breaks_limits() -> Result<()> {

0 commit comments

Comments
 (0)