You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "wolffcm (via GitHub)" <gi...@apache.org> on 2023/05/17 17:06:26 UTC

[GitHub] [arrow-datafusion] wolffcm commented on a diff in pull request #6369: feat: add pattern for simplifying exprs like `str ~ '^foo$'`

wolffcm commented on code in PR #6369:
URL: https://github.com/apache/arrow-datafusion/pull/6369#discussion_r1196824908


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -2434,6 +2434,21 @@ mod tests {
         // single word
         assert_change(regex_match(col("c1"), lit("foo")), like(col("c1"), "%foo%"));
 
+        // regular expressions that match an exact literal
+        assert_change(regex_match(col("c1"), lit("^$")), col("c1").eq(lit("")));
+        assert_change(
+            regex_not_match(col("c1"), lit("^$")),
+            col("c1").not_eq(lit("")),
+        );
+        assert_change(
+            regex_match(col("c1"), lit("^foo$")),
+            col("c1").eq(lit("foo")),
+        );
+        assert_change(
+            regex_not_match(col("c1"), lit("^foo$")),
+            col("c1").not_eq(lit("foo")),
+        );

Review Comment:
   Done, also added a test that combines anchored regexes with OR-chains, since `lower_simple` is called recursively for that case.



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org