ygf11 commented on code in PR #4826: URL: https://github.com/apache/arrow-datafusion/pull/4826#discussion_r1064000340
########## datafusion/optimizer/src/decorrelate_where_in.rs: ########## @@ -205,6 +220,72 @@ fn optimize_where_in( Ok(new_plan) } +fn extract_join_filters(maybe_filter: &LogicalPlan) -> Result<(Vec<Expr>, LogicalPlan)> { + if let LogicalPlan::Filter(plan_filter) = maybe_filter { + let input_schema = plan_filter.input.schema(); + let subquery_filter_exprs = split_conjunction(&plan_filter.predicate); + + let mut join_filters: Vec<Expr> = vec![]; + let mut subquery_filters: Vec<Expr> = vec![]; + for expr in subquery_filter_exprs { + let cols = expr.to_columns()?; + if check_all_column_from_schema(&cols, input_schema.clone()) { + subquery_filters.push(expr.clone()); + } else { + join_filters.push(expr.clone()) + } Review Comment: If the expression depends on the outer table, we should move it to the join predicate. -- 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