Fix Empty InDimFilter Failure (#6330)

* fix empty InDimFilter failure (#6101)

* Add test case for empty values input

* Add documentation for empty values in InDimFilter
This commit is contained in:
robertervin 2018-10-14 23:43:16 -04:00 committed by Slim Bouguerra
parent 84598fba3b
commit 95ab1ea737
3 changed files with 14 additions and 1 deletions

View File

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

View File

@ -77,7 +77,7 @@ public class InDimFilter implements DimFilter
)
{
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) {

View File

@ -92,6 +92,11 @@ public class InFilterTest extends BaseFilterTest
@Test
public void testSingleValueStringColumnWithoutNulls()
{
assertFilterMatches(
toInFilter("dim0"),
ImmutableList.of()
);
assertFilterMatches(
toInFilter("dim0", null),
ImmutableList.of()
@ -342,6 +347,12 @@ public class InFilterTest extends BaseFilterTest
}
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);