izveigor commented on code in PR #5511:
URL: https://github.com/apache/arrow-datafusion/pull/5511#discussion_r1129152194


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -2227,87 +2069,86 @@ mod tests {
     #[test]
     fn test_simplify_or_and_non_null() {
         let l = col("c2_non_null").gt(lit(5));
-        let r = binary_expr(
-            col("c1_non_null").lt(lit(6)),
-            Operator::And,
-            col("c2_non_null").gt(lit(5)),
-        );
+        let r = and(col("c1_non_null").lt(lit(6)), 
col("c2_non_null").gt(lit(5)));
 
         // (c2 > 5) OR ((c1 < 6) AND (c2 > 5)) --> c2 > 5
-        let expr = binary_expr(l.clone(), Operator::Or, r.clone());
+        let expr = or(l.clone(), r.clone());
 
         // This is only true if `c1 < 6` is not nullable / can not be null.
         let expected = col("c2_non_null").gt(lit(5));
 
         assert_eq!(simplify(expr), expected);
 
         // ((c1 < 6) AND (c2 > 5)) OR (c2 > 5) --> c2 > 5
-        let expr = binary_expr(l, Operator::Or, r);
+        let expr = or(l, r);
 
         assert_eq!(simplify(expr), expected);
     }
 
     #[test]
     fn test_simplify_and_or() {
         let l = col("c2").gt(lit(5));
-        let r = binary_expr(col("c1").lt(lit(6)), Operator::Or, 
col("c2").gt(lit(5)));
+        let r = or(col("c1").lt(lit(6)), col("c2").gt(lit(5)));
 
         // (c2 > 5) AND ((c1 < 6) OR (c2 > 5)) --> c2 > 5
-        let expr = binary_expr(l.clone(), Operator::And, r.clone());
+        let expr = and(l.clone(), r.clone());
 
         // no rewrites if c1 can be null
         let expected = expr.clone();
         assert_eq!(simplify(expr), expected);
 
         // ((c1 < 6) OR (c2 > 5)) AND (c2 > 5) --> c2 > 5
-        let expr = binary_expr(l, Operator::And, r);
+        let expr = and(l, r);
         let expected = expr.clone();
         assert_eq!(simplify(expr), expected);
     }
 
     #[test]
     fn test_simplify_and_or_non_null() {
         let l = col("c2_non_null").gt(lit(5));
-        let r = binary_expr(
-            col("c1_non_null").lt(lit(6)),
-            Operator::Or,
-            col("c2_non_null").gt(lit(5)),
-        );
+        let r = or(col("c1_non_null").lt(lit(6)), 
col("c2_non_null").gt(lit(5)));
 
         // (c2 > 5) AND ((c1 < 6) OR (c2 > 5)) --> c2 > 5
-        let expr = binary_expr(l.clone(), Operator::And, r.clone());
+        let expr = and(l.clone(), r.clone());
 
         // This is only true if `c1 < 6` is not nullable / can not be null.
         let expected = col("c2_non_null").gt(lit(5));
 
         assert_eq!(simplify(expr), expected);
 
         // ((c1 < 6) OR (c2 > 5)) AND (c2 > 5) --> c2 > 5
-        let expr = binary_expr(l, Operator::And, r);
+        let expr = and(l, r);
 
         assert_eq!(simplify(expr), expected);
     }
 
     #[test]
     fn test_simplify_null_and_false() {
-        let expr = binary_expr(lit_bool_null(), Operator::And, lit(false));
+        let expr = and(lit_bool_null(), lit(false));
         let expr_eq = lit(false);
 
         assert_eq!(simplify(expr), expr_eq);
     }
 
     #[test]
     fn test_simplify_divide_null_by_null() {
-        let null = Expr::Literal(ScalarValue::Int32(None));
-        let expr_plus = binary_expr(null.clone(), Operator::Divide, 
null.clone());
+        let null = lit(ScalarValue::Int32(None));
+        let expr_plus = null.clone() / null.clone();
         let expr_eq = null;
 
         assert_eq!(simplify(expr_plus), expr_eq);
     }
 
     #[test]
     fn test_simplify_simplify_arithmetic_expr() {
-        let expr_plus = binary_expr(lit(1), Operator::Plus, lit(1));
+        let expr_plus = lit(1) + lit(1);
+
+        assert_eq!(simplify(expr_plus), lit(2));
+    }
+
+    #[test]
+    fn test_simplify_simplify_eq_expr() {

Review Comment:
   I think check of `expr_plus` in `test_simplify_simplify_eq_expr` is 
redundant because it is already checked in 
`test_simplify_simplify_arithmetic_expr`



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

Reply via email to