mirror of https://github.com/apache/druid.git
fix bug with like filter on missing columns not correctly considering extractionFn (#16037)
This commit is contained in:
parent
566013a5f5
commit
6e3b33d8c2
|
@ -25,6 +25,7 @@ import org.apache.druid.java.util.common.IAE;
|
|||
import org.apache.druid.query.extraction.ExtractionFn;
|
||||
import org.apache.druid.query.filter.ColumnIndexSelector;
|
||||
import org.apache.druid.query.filter.DimFilter;
|
||||
import org.apache.druid.query.filter.DruidPredicateMatch;
|
||||
import org.apache.druid.query.filter.Filter;
|
||||
import org.apache.druid.query.filter.FilterTuning;
|
||||
import org.apache.druid.query.filter.LikeDimFilter;
|
||||
|
@ -35,8 +36,6 @@ import org.apache.druid.segment.ColumnInspector;
|
|||
import org.apache.druid.segment.ColumnProcessors;
|
||||
import org.apache.druid.segment.ColumnSelectorFactory;
|
||||
import org.apache.druid.segment.column.ColumnIndexSupplier;
|
||||
import org.apache.druid.segment.index.AllTrueBitmapColumnIndex;
|
||||
import org.apache.druid.segment.index.AllUnknownBitmapColumnIndex;
|
||||
import org.apache.druid.segment.index.BitmapColumnIndex;
|
||||
import org.apache.druid.segment.index.semantic.LexicographicalRangeIndexes;
|
||||
import org.apache.druid.segment.index.semantic.StringValueSetIndexes;
|
||||
|
@ -76,10 +75,9 @@ public class LikeFilter implements Filter
|
|||
}
|
||||
final ColumnIndexSupplier indexSupplier = selector.getIndexSupplier(dimension);
|
||||
if (indexSupplier == null) {
|
||||
// Treat this as a column full of nulls
|
||||
return likeMatcher.matches(null).matches(false)
|
||||
? new AllTrueBitmapColumnIndex(selector)
|
||||
: new AllUnknownBitmapColumnIndex(selector);
|
||||
final String nullValue = extractionFn == null ? null : extractionFn.apply(null);
|
||||
final DruidPredicateMatch match = likeMatcher.matches(nullValue);
|
||||
return Filters.makeMissingColumnNullIndex(match, selector);
|
||||
}
|
||||
if (isSimpleEquals()) {
|
||||
StringValueSetIndexes valueIndexes = indexSupplier.as(StringValueSetIndexes.class);
|
||||
|
|
|
@ -33,10 +33,12 @@ import org.apache.druid.data.input.impl.TimestampSpec;
|
|||
import org.apache.druid.java.util.common.DateTimes;
|
||||
import org.apache.druid.java.util.common.IAE;
|
||||
import org.apache.druid.java.util.common.Pair;
|
||||
import org.apache.druid.query.extraction.MapLookupExtractor;
|
||||
import org.apache.druid.query.extraction.SubstringDimExtractionFn;
|
||||
import org.apache.druid.query.filter.Filter;
|
||||
import org.apache.druid.query.filter.LikeDimFilter;
|
||||
import org.apache.druid.query.filter.NotDimFilter;
|
||||
import org.apache.druid.query.lookup.LookupExtractionFn;
|
||||
import org.apache.druid.segment.IndexBuilder;
|
||||
import org.apache.druid.segment.StorageAdapter;
|
||||
import org.apache.druid.segment.column.ColumnType;
|
||||
|
@ -260,6 +262,27 @@ public class LikeFilterTest extends BaseFilterTest
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonNullableExtractionFnMissingColumn()
|
||||
{
|
||||
final LookupExtractionFn extractionFn = new LookupExtractionFn(
|
||||
new MapLookupExtractor(ImmutableMap.of("foo", "bar"), false),
|
||||
false,
|
||||
"replaced",
|
||||
false,
|
||||
false
|
||||
);
|
||||
final LikeDimFilter filter = new LikeDimFilter("fake", "__DOESNT_EXIST__%", null, extractionFn);
|
||||
assertFilterMatches(
|
||||
filter,
|
||||
ImmutableList.of()
|
||||
);
|
||||
assertFilterMatches(
|
||||
NotDimFilter.of(filter),
|
||||
ImmutableList.of("0", "1", "2", "3", "4", "5", "6")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWildcardMatchWithEscape()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue