avantgardnerio commented on code in PR #2885: URL: https://github.com/apache/arrow-datafusion/pull/2885#discussion_r925944286
########## datafusion/optimizer/src/utils.rs: ########## @@ -65,6 +67,41 @@ pub fn split_conjunction<'a>(predicate: &'a Expr, predicates: &mut Vec<&'a Expr> } } +/// Recursively scans a slice of expressions for any `Or` operators +/// +/// # Arguments +/// +/// * `predicates` - the expressions to scan +/// +/// # Return value +/// +/// True if an `Or` operator was found +pub fn has_disjunction(predicates: &[&Expr]) -> bool { + for predicate in predicates.iter() { + match predicate { + Expr::BinaryExpr { + left: _, + op: Operator::Or, + right: _, + } => { + return true; + } + Expr::BinaryExpr { right, op: _, left } => { + if has_disjunction(&[&**left, &**right]) { + return true; + } + } + Expr::Alias(expr, _) => { + if has_disjunction(&[&**expr]) { + return true; + } + } + _ => {} Review Comment: Thanks! I was worried I'd miss something with that code, and I didn't know about `ExpressionVisitor`... I'll switch over :+1: -- 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