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 class LikeDimFilter implements DimFilter 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 class LikeFilterTest extends BaseFilterTest ); } + @Test + public void testEscapeEscapingItself() + { + assertFilterMatches( + new LikeDimFilter("dim1", "foooo", "o", null), + ImmutableList.of("1") + ); + } + @Test public void testSuffixMatchWithExtractionFn() {