erratic-pattern commented on code in PR #10358:
URL: https://github.com/apache/datafusion/pull/10358#discussion_r1588553331
##########
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);
Review Comment:
@alamb I've added the other examples from the comments you linked. So far
this one is the only one that runs up to 3 iterations.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]