alamb commented on code in PR #10358: URL: https://github.com/apache/datafusion/pull/10358#discussion_r1589068451
########## datafusion/optimizer/Cargo.toml: ########## @@ -53,5 +53,6 @@ log = { workspace = true } regex-syntax = "0.8.0" [dev-dependencies] ctor = { workspace = true } +datafusion-functions = { workspace = true } Review Comment: > I'll need to make simplify_inner public in order to move the tests I think that would be fine too as long as the doc comments explain that ########## datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs: ########## @@ -450,6 +463,9 @@ impl<'a> TreeNodeRewriter for ConstEvaluator<'a> { ConstSimplifyResult::Simplified(s) => { Ok(Transformed::yes(Expr::Literal(s))) } + ConstSimplifyResult::NotSimplified(s) => { Review Comment: As long as we can avoid copying the Expr then this seems like a good idea to me ❤️ ########## datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs: ########## @@ -3575,4 +3608,48 @@ mod tests { assert_eq!(simplify(expr), expected); } + + #[test] + fn test_simplify_iterations() { + // TRUE + let expr = lit(true); + let expected = lit(true); + let (expr, num_iter) = simplify_count(expr); + assert_eq!(expr, expected); + assert_eq!(num_iter, 1); + + // (true != NULL) OR (5 > 10) + let expr = lit(true).not_eq(lit_bool_null()).or(lit(5).gt(lit(10))); + let expected = lit_bool_null(); + let (expr, num_iter) = simplify_count(expr); + assert_eq!(expr, expected); + assert_eq!(num_iter, 2); Review Comment: cool -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org