Fix NullFilter getDimensionRangeSet. (#15500)

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.
This commit is contained in:
Gian Merlino 2023-12-06 01:39:59 -08:00 committed by GitHub
parent f4949afdd7
commit 6f51155ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -114,6 +114,10 @@ public class NullFilter extends AbstractOptimizableDimFilter implements Filter
@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(""));

View File

@ -23,6 +23,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
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 org.junit.runners.Parameterized;
import java.io.Closeable;
import java.util.Arrays;
import java.util.Collections;
@RunWith(Enclosed.class)
public class NullFilterTests
@ -310,6 +313,19 @@ public class NullFilterTests
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
{