erratic-pattern commented on code in PR #10358:
URL: https://github.com/apache/datafusion/pull/10358#discussion_r1588552047


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -3575,4 +3604,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);
+
+        // cast(now() as int64) < cast(to_timestamp(0) as int64) + i64::MAX
+        let expr = cast(now(), DataType::Int64)
+            .lt(cast(to_timestamp(vec![lit(0)]), DataType::Int64) + 
lit(i64::MAX));
+        let expected = lit(true);
+        let (expr, num_iter) = simplify_count(expr);
+        assert_eq!(expr, expected);
+        assert_eq!(num_iter, 3);
+
+        // NOTE: this currently does not simplify
+        // (((c4 - 10) + 10) *100) / 100

Review Comment:
   note that one of @devinjdangelo 's examples did not simplify. I think we 
would need to rebalance parens in the simplifier or maybe the canonicalizer for 
that to work.



-- 
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

Reply via email to