You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2018/10/15 03:43:18 UTC

[GitHub] b-slim closed pull request #6330: Fix Empty InDimFilter Failure

b-slim closed pull request #6330: Fix Empty InDimFilter Failure
URL: https://github.com/apache/incubator-druid/pull/6330
 
 
   

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/docs/content/querying/filters.md b/docs/content/querying/filters.md
index f0d75fa2ae1..0bf4166d2a1 100644
--- a/docs/content/querying/filters.md
+++ b/docs/content/querying/filters.md
@@ -213,6 +213,8 @@ The grammar for a IN filter is as follows:
 
 The IN filter supports the use of extraction functions, see [Filtering with Extraction Functions](#filtering-with-extraction-functions) for details.
 
+If an empty `values` array is passed to the IN filter, it will simply return an empty result.
+
 ### Like filter
 
 Like filters can be used for basic wildcard searches. They are equivalent to the SQL LIKE operator. Special characters
diff --git a/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java b/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java
index 7f63acf9986..27a371960f8 100644
--- a/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java
+++ b/processing/src/main/java/org/apache/druid/query/filter/InDimFilter.java
@@ -77,7 +77,7 @@ public InDimFilter(
   )
   {
     Preconditions.checkNotNull(dimension, "dimension can not be null");
-    Preconditions.checkArgument(values != null && !values.isEmpty(), "values can not be null or empty");
+    Preconditions.checkArgument(values != null, "values can not be null");
 
     this.values = new TreeSet<>(Comparators.naturalNullsFirst());
     for (String value : values) {
diff --git a/processing/src/test/java/org/apache/druid/segment/filter/InFilterTest.java b/processing/src/test/java/org/apache/druid/segment/filter/InFilterTest.java
index 74a1fd84071..c9d824fb681 100644
--- a/processing/src/test/java/org/apache/druid/segment/filter/InFilterTest.java
+++ b/processing/src/test/java/org/apache/druid/segment/filter/InFilterTest.java
@@ -92,6 +92,11 @@ public static void tearDown() throws Exception
   @Test
   public void testSingleValueStringColumnWithoutNulls()
   {
+    assertFilterMatches(
+        toInFilter("dim0"),
+        ImmutableList.of()
+    );
+
     assertFilterMatches(
         toInFilter("dim0", null),
         ImmutableList.of()
@@ -342,6 +347,12 @@ public void testMatchWithLookupExtractionFn()
 
   }
 
+  private DimFilter toInFilter(String dim)
+  {
+    List<String> emptyList = Lists.newArrayList();
+    return new InDimFilter(dim, emptyList, null);
+  }
+
   private DimFilter toInFilter(String dim, String value, String... values)
   {
     return new InDimFilter(dim, Lists.asList(value, values), null);


 

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