diff --git a/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java b/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java index 14bdb6f4185e..da737bdce890 100644 --- a/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java +++ b/processing/src/main/java/org/apache/druid/query/filter/NullFilter.java @@ -114,6 +114,10 @@ public Filter toFilter() @Override public RangeSet getDimensionRangeSet(String dimension) { + if (!Objects.equals(getColumn(), dimension)) { + return null; + } + RangeSet retSet = TreeRangeSet.create(); // Nulls are less than empty String in segments retSet.add(Range.lessThan("")); diff --git a/processing/src/test/java/org/apache/druid/segment/filter/NullFilterTests.java b/processing/src/test/java/org/apache/druid/segment/filter/NullFilterTests.java index b123ead53a54..084c1c24c2bf 100644 --- a/processing/src/test/java/org/apache/druid/segment/filter/NullFilterTests.java +++ b/processing/src/test/java/org/apache/druid/segment/filter/NullFilterTests.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Range; +import com.google.common.collect.TreeRangeSet; import nl.jqno.equalsverifier.EqualsVerifier; import org.apache.druid.common.config.NullHandling; import org.apache.druid.jackson.DefaultObjectMapper; @@ -41,6 +43,7 @@ import java.io.Closeable; import java.util.Arrays; +import java.util.Collections; @RunWith(Enclosed.class) public class NullFilterTests @@ -310,6 +313,19 @@ public void testArrays() public static class NullFilterNonParameterizedTest { + @Test + public void testGetDimensionRangeSet() + { + final NullFilter filter = new NullFilter("x", null); + + Assert.assertEquals( + TreeRangeSet.create(Collections.singleton(Range.lessThan(""))), + filter.getDimensionRangeSet("x") + ); + + Assert.assertNull(filter.getDimensionRangeSet("y")); + } + @Test public void testSerde() throws JsonProcessingException {