Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(optimizer): reduce expr tree depth when merge logical operations #17342

Merged
merged 11 commits into from
Jun 21, 2024
Prev Previous commit
Next Next commit
apply to null safe eq
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
  • Loading branch information
BugenZhao committed Jun 19, 2024
commit 447d3c0e8ec7f2d09cae4191471914c7038e5f5e
19 changes: 6 additions & 13 deletions src/frontend/src/optimizer/rule/intersect_to_semi_join_rule.rs
Original file line number Diff line number Diff line change
@@ -50,14 +50,14 @@ impl Rule for IntersectToSemiJoinRule {

impl IntersectToSemiJoinRule {
pub(crate) fn gen_null_safe_equal(left: PlanRef, right: PlanRef) -> ExprImpl {
(left
let arms = (left
.schema()
.fields()
.iter()
.zip_eq_debug(right.schema().fields())
.enumerate())
.fold(None, |expr, (i, (left_field, right_field))| {
let equal = ExprImpl::FunctionCall(Box::new(FunctionCall::new_unchecked(
.map(|(i, (left_field, right_field))| {
ExprImpl::FunctionCall(Box::new(FunctionCall::new_unchecked(
ExprType::IsNotDistinctFrom,
vec![
ExprImpl::InputRef(Box::new(InputRef::new(i, left_field.data_type()))),
@@ -67,16 +67,9 @@ impl IntersectToSemiJoinRule {
))),
],
Boolean,
)));

match expr {
None => Some(equal),
Some(expr) => Some(ExprImpl::FunctionCall(Box::new(
FunctionCall::new_unchecked(ExprType::And, vec![expr, equal], Boolean),
))),
}
})
.unwrap()
)))
});
ExprImpl::and(arms)
}
}

Loading