Dandandan commented on code in PR #2885:
URL: https://github.com/apache/arrow-datafusion/pull/2885#discussion_r919275532


##########
datafusion/optimizer/src/utils.rs:
##########
@@ -82,6 +85,127 @@ pub fn add_filter(plan: LogicalPlan, predicates: &[&Expr]) 
-> LogicalPlan {
     })
 }
 
+/// Looks for correlating expressions: equality expressions with one field 
from the subquery, and
+/// one not in the subquery (closed upon from outer scope)
+///
+/// # Arguments
+///
+/// * `exprs` - List of expressions that may or may not be joins
+/// * `fields` - HashSet of fully qualified (table.col) fields in subquery 
schema
+///
+/// # Return value
+///
+/// Tuple of (expressions containing joins, remaining non-join expressions)
+pub fn find_join_exprs(
+    exprs: Vec<&Expr>,
+    schema: &DFSchemaRef,
+) -> (Vec<Expr>, Vec<Expr>) {
+    let fields: HashSet<_> = schema
+        .fields()
+        .iter()
+        .map(|it| it.qualified_name())
+        .collect();
+
+    let (joins, others): (Vec<_>, Vec<_>) = 
exprs.iter().partition_map(|filter| {

Review Comment:
   I think it's smart/elegant, but in this case it might be more readable (and 
avoids the extra dependency) to push into two vecs for the j`oins` / `other` 
than use `partition_map` + `Either::Right` / `Either::Left`..



-- 
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: github-unsubscr...@arrow.apache.org

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

Reply via email to