alamb commented on code in PR #13260:
URL: https://github.com/apache/datafusion/pull/13260#discussion_r1831471559


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -3633,32 +3697,123 @@ mod tests {
 
     #[test]
     fn test_like_and_ilke() {
-        // LIKE '%'
-        let expr = like(col("c1"), "%");
+        let null = lit(ScalarValue::Utf8(None));
+
+        // expr [NOT] [I]LIKE NULL
+        let expr = like(col("c1"), null.clone());
+        assert_eq!(simplify(expr), lit_bool_null());
+
+        let expr = not_like(col("c1"), null.clone());
+        assert_eq!(simplify(expr), lit_bool_null());
+
+        let expr = ilike(col("c1"), null.clone());
+        assert_eq!(simplify(expr), lit_bool_null());
+
+        let expr = not_ilike(col("c1"), null.clone());
+        assert_eq!(simplify(expr), lit_bool_null());
+
+        // expr [NOT] [I]LIKE '%'
+        let expr = like(col("c1"), lit("%"));
+        assert_eq!(simplify(expr), if_not_null(col("c1"), true));
+
+        let expr = not_like(col("c1"), lit("%"));
+        assert_eq!(simplify(expr), if_not_null(col("c1"), false));
+
+        let expr = ilike(col("c1"), lit("%"));
+        assert_eq!(simplify(expr), if_not_null(col("c1"), true));
+
+        let expr = not_ilike(col("c1"), lit("%"));
+        assert_eq!(simplify(expr), if_not_null(col("c1"), false));
+
+        // expr [NOT] [I]LIKE '%%'

Review Comment:
   I was definitely confused -- thank you



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