Skip to content

Commit

Permalink
Fix NullFilter getDimensionRangeSet. (apache#15500)
Browse files Browse the repository at this point in the history
It wasn't checking the column name, so it would return a domain regardless
of the input column. This means that null filters on data sources with range
partitioning would lead to excessive pruning of segments, and therefore
missing results.
  • Loading branch information
gianm authored and LakshSingla committed Dec 7, 2023
1 parent f7e34e7 commit 1714c45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public Filter toFilter()
@Override
public RangeSet<String> getDimensionRangeSet(String dimension)
{
if (!Objects.equals(getColumn(), dimension)) {
return null;
}

RangeSet<String> retSet = TreeRangeSet.create();
// Nulls are less than empty String in segments
retSet.add(Range.lessThan(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,6 +43,7 @@

import java.io.Closeable;
import java.util.Arrays;
import java.util.Collections;

@RunWith(Enclosed.class)
public class NullFilterTests
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 1714c45

Please sign in to comment.