Skip to content

Commit d71dacc

Browse files
committed
Rename helper for scalar subquery clarity
Update the function name to specify its relevance to scalar subquery cross-joins. Add an intent comment for better understanding of its purpose. Replace the old function call in join predicate handling for improved readability.
1 parent 726bf17 commit d71dacc

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,12 @@ fn is_derived_relation(plan: &LogicalPlan) -> bool {
308308
matches!(plan, LogicalPlan::SubqueryAlias(_))
309309
}
310310

311-
fn should_keep_filter_above_cross_join(join: &Join, predicate: &Expr) -> bool {
311+
// Keep post-join filters above certain scalar-subquery cross joins to preserve
312+
// behavior for the window-over-scalar-subquery regression shape.
313+
fn should_keep_filter_above_scalar_subquery_cross_join(
314+
join: &Join,
315+
predicate: &Expr,
316+
) -> bool {
312317
if !join.on.is_empty() || join.filter.is_some() {
313318
return false;
314319
}
@@ -471,7 +476,7 @@ fn push_down_all_join(
471476
} else if right_preserved && checker.is_right_only(&predicate) {
472477
right_push.push(predicate);
473478
} else if is_inner_join
474-
&& !should_keep_filter_above_cross_join(&join, &predicate)
479+
&& !should_keep_filter_above_scalar_subquery_cross_join(&join, &predicate)
475480
&& can_evaluate_as_join_condition(&predicate)?
476481
{
477482
// Here we do not differ it is eq or non-eq predicate, ExtractEquijoinPredicate will extract the eq predicate

datafusion/optimizer/src/utils.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -492,29 +492,19 @@ mod tests {
492492
}
493493

494494
#[test]
495-
fn mixed_reference_predicate_remains_fast_pathed_in_authoritative_mode(
496-
) -> Result<()> {
495+
fn mixed_reference_predicate_remains_fast_pathed_in_authoritative_mode() -> Result<()>
496+
{
497497
let predicate = binary_expr(col("a"), Operator::Gt, col("b"));
498498
let column_a = Column::from_name("a");
499499

500500
let auto_result = with_null_restriction_eval_mode_for_test(
501501
NullRestrictionEvalMode::Auto,
502-
|| {
503-
is_restrict_null_predicate(
504-
predicate.clone(),
505-
std::iter::once(&column_a),
506-
)
507-
},
502+
|| is_restrict_null_predicate(predicate.clone(), std::iter::once(&column_a)),
508503
)?;
509504

510505
let authoritative_only_result = with_null_restriction_eval_mode_for_test(
511506
NullRestrictionEvalMode::AuthoritativeOnly,
512-
|| {
513-
is_restrict_null_predicate(
514-
predicate.clone(),
515-
std::iter::once(&column_a),
516-
)
517-
},
507+
|| is_restrict_null_predicate(predicate.clone(), std::iter::once(&column_a)),
518508
)?;
519509

520510
assert!(!auto_result, "{predicate}");

0 commit comments

Comments
 (0)