You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by "Lordworms (via GitHub)" <gi...@apache.org> on 2024/04/21 22:10:44 UTC

[PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Lordworms opened a new pull request, #10165:
URL: https://github.com/apache/datafusion/pull/10165

   ## Which issue does this PR close?
   part of #9637 
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1575341213


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,66 +88,97 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {

Review Comment:
   You might be able to avoid a level of indenting if you did the entire match here, like:
   
   ```
    match plan {
               LogicalPlan::Join(Join {
                   left,
                   right,
                   mut on,
                   filter: Some(expr),
                   join_type,
                   join_constraint,
               }) => {
   ```
   
   Then you could avoid reassembling LogicalPlan::Join as well



##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {

Review Comment:
   I think there is already a function that does this: https://docs.rs/datafusion/latest/datafusion/logical_expr/utils/fn.split_conjunction_owned.html



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573934058


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();

Review Comment:
   here to avoid clone of vector on



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1575372225


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {

Review Comment:
   ok got it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573935050


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {

Review Comment:
   here implement a ownership version of split conjunction to avoid clone for refrence



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10165:
URL: https://github.com/apache/datafusion/pull/10165


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573935050


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {

Review Comment:
   here implement a ownership version of split conjunction to avoid clone while passing reference



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573934306


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {
+    split_conjunction_own_impl(expr, vec![])
+}
 
-    fn apply_order(&self) -> Option<ApplyOrder> {
-        Some(ApplyOrder::BottomUp)
+fn split_conjunction_own_impl(mut expr: Expr, mut exprs: Vec<Expr>) -> Vec<Expr> {
+    match expr {
+        Expr::BinaryExpr(BinaryExpr {
+            right,
+            op: Operator::And,
+            left,
+        }) => {
+            let mut left_exprs = split_conjunction_own_impl(*left, vec![]);
+            let mut right_exprs = split_conjunction_own_impl(*right, vec![]);
+            left_exprs.append(&mut right_exprs);
+            left_exprs
+        }
+        Expr::Alias(Alias { expr, .. }) => split_conjunction_own_impl(*expr, exprs),
+        other => {
+            exprs.push(other);
+            exprs
+        }
     }
 }
 
 fn split_eq_and_noneq_join_predicate(
-    filter: &Expr,

Review Comment:
   here we directly split filter to avoid further clone 



##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -141,13 +193,13 @@ fn split_eq_and_noneq_join_predicate(
                     if can_hash(&left_expr_type) && can_hash(&right_expr_type) {
                         accum_join_keys.push((left_expr, right_expr));
                     } else {
-                        accum_filters.push(expr.clone());

Review Comment:
   avoid clone 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573935050


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,
+                    if !equijoin_predicates.is_empty() {
+                        on.extend(equijoin_predicates);
+                        Ok(Transformed::yes(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
+                            filter: non_equijoin_expr,
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    } else {
+                        Ok(Transformed::no(LogicalPlan::Join(Join {
+                            left,
+                            right,
+                            on,
                             filter: non_equijoin_expr,
-                            join_type: *join_type,
-                            join_constraint: *join_constraint,
-                            schema: schema.clone(),
-                            null_equals_null: *null_equals_null,
-                        })
-                    });
-
-                    Ok(optimized_plan)
-                })
+                            join_type,
+                            join_constraint,
+                            schema,
+                            null_equals_null,
+                        })))
+                    }
+                } else {
+                    Ok(Transformed::no(LogicalPlan::Join(Join {
+                        left,
+                        right,
+                        on,
+                        filter,
+                        join_type,
+                        join_constraint,
+                        schema,
+                        null_equals_null,
+                    })))
+                }
             }
-            _ => Ok(None),
+            _ => Ok(Transformed::no(plan)),
         }
     }
+}
 
-    fn name(&self) -> &str {
-        "extract_equijoin_predicate"
-    }
+/// split with ownership
+fn split_conjunction_own(expr: Expr) -> Vec<Expr> {

Review Comment:
   here implement a ownership version of split conjunction



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


Re: [PR] implement rewrite for ExtractEquijoinPredicate and avoid clone in filter [datafusion]

Posted by "Lordworms (via GitHub)" <gi...@apache.org>.
Lordworms commented on code in PR #10165:
URL: https://github.com/apache/datafusion/pull/10165#discussion_r1573934151


##########
datafusion/optimizer/src/extract_equijoin_predicate.rs:
##########
@@ -67,69 +88,100 @@ impl OptimizerRule for ExtractEquijoinPredicate {
             }) => {
                 let left_schema = left.schema();
                 let right_schema = right.schema();
-
-                filter.as_ref().map_or(Result::Ok(None), |expr| {
+                if let Some(expr) = filter {
                     let (equijoin_predicates, non_equijoin_expr) =
                         split_eq_and_noneq_join_predicate(
                             expr,
                             left_schema,
                             right_schema,
                         )?;
 
-                    let optimized_plan = (!equijoin_predicates.is_empty()).then(|| {
-                        let mut new_on = on.clone();
-                        new_on.extend(equijoin_predicates);
-
-                        LogicalPlan::Join(Join {
-                            left: left.clone(),
-                            right: right.clone(),
-                            on: new_on,

Review Comment:
   here to avoid clone of arc



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org