druid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] fjy closed pull request #6295: Like filter: Fix escapes escaping themselves.
Date Wed, 05 Sep 2018 16:29:08 GMT
fjy closed pull request #6295: Like filter: Fix escapes escaping themselves.
URL: https://github.com/apache/incubator-druid/pull/6295
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/processing/src/main/java/org/apache/druid/query/filter/LikeDimFilter.java b/processing/src/main/java/org/apache/druid/query/filter/LikeDimFilter.java
index 50022390668..e7ec2fcc2d6 100644
--- a/processing/src/main/java/org/apache/druid/query/filter/LikeDimFilter.java
+++ b/processing/src/main/java/org/apache/druid/query/filter/LikeDimFilter.java
@@ -116,7 +116,7 @@ public static LikeMatcher from(
       SuffixMatch suffixMatch = SuffixMatch.MATCH_EMPTY;
       for (int i = 0; i < likePattern.length(); i++) {
         final char c = likePattern.charAt(i);
-        if (escapeChar != null && c == escapeChar) {
+        if (escapeChar != null && c == escapeChar && !escaping) {
           escaping = true;
         } else if (c == '%' && !escaping) {
           inPrefix = false;
diff --git a/processing/src/test/java/org/apache/druid/segment/filter/LikeFilterTest.java
b/processing/src/test/java/org/apache/druid/segment/filter/LikeFilterTest.java
index cc646643ea6..b6ac4f04046 100644
--- a/processing/src/test/java/org/apache/druid/segment/filter/LikeFilterTest.java
+++ b/processing/src/test/java/org/apache/druid/segment/filter/LikeFilterTest.java
@@ -206,6 +206,15 @@ public void testUnderscoreMatch()
     );
   }
 
+  @Test
+  public void testEscapeEscapingItself()
+  {
+    assertFilterMatches(
+        new LikeDimFilter("dim1", "foooo", "o", null),
+        ImmutableList.of("1")
+    );
+  }
+
   @Test
   public void testSuffixMatchWithExtractionFn()
   {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Mime
View raw message