use of io.druid.query.filter.RegexDimFilter in project druid by druid-io.
the class RegexFilterTest method testMissingColumnNotSpecifiedInDimensionList.
@Test
public void testMissingColumnNotSpecifiedInDimensionList() {
assertFilterMatches(new RegexDimFilter("dim4", "", null), ImmutableList.<String>of());
assertFilterMatches(new RegexDimFilter("dim4", "a", null), ImmutableList.<String>of());
assertFilterMatches(new RegexDimFilter("dim4", "b", null), ImmutableList.<String>of());
assertFilterMatches(new RegexDimFilter("dim4", "c", null), ImmutableList.<String>of());
}
use of io.druid.query.filter.RegexDimFilter in project druid by druid-io.
the class RegexFilterTest method testSingleValueStringColumnWithoutNulls.
@Test
public void testSingleValueStringColumnWithoutNulls() {
assertFilterMatches(new RegexDimFilter("dim0", ".*", null), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new RegexDimFilter("dim0", "0", null), ImmutableList.of("0"));
assertFilterMatches(new RegexDimFilter("dim0", "5", null), ImmutableList.of("5"));
}
use of io.druid.query.filter.RegexDimFilter in project druid by druid-io.
the class RegexFilterTest method testMultiValueStringColumn.
@Test
public void testMultiValueStringColumn() {
assertFilterMatches(new RegexDimFilter("dim2", ".*", null), ImmutableList.of("0", "3", "4"));
assertFilterMatches(new RegexDimFilter("dim2", "a", null), ImmutableList.of("0", "3"));
assertFilterMatches(new RegexDimFilter("dim2", "b", null), ImmutableList.of("0"));
assertFilterMatches(new RegexDimFilter("dim2", "c", null), ImmutableList.of("4"));
assertFilterMatches(new RegexDimFilter("dim2", "d", null), ImmutableList.<String>of());
}
use of io.druid.query.filter.RegexDimFilter in project druid by druid-io.
the class RegexFilterTest method testRegexWithExtractionFn.
@Test
public void testRegexWithExtractionFn() {
String nullJsFn = "function(str) { if (str === null) { return 'NOT_NULL_ANYMORE'; } else { return str;} }";
ExtractionFn changeNullFn = new JavaScriptExtractionFn(nullJsFn, false, JavaScriptConfig.getEnabledInstance());
assertFilterMatches(new RegexDimFilter("dim1", ".*ANYMORE", changeNullFn), ImmutableList.of("0"));
assertFilterMatches(new RegexDimFilter("dim1", "ab.*", changeNullFn), ImmutableList.<String>of("4", "5"));
assertFilterMatches(new RegexDimFilter("dim2", ".*ANYMORE", changeNullFn), ImmutableList.of("1", "2", "5"));
assertFilterMatches(new RegexDimFilter("dim2", "a.*", changeNullFn), ImmutableList.of("0", "3"));
assertFilterMatches(new RegexDimFilter("dim3", ".*ANYMORE", changeNullFn), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new RegexDimFilter("dim3", "a.*", changeNullFn), ImmutableList.<String>of());
assertFilterMatches(new RegexDimFilter("dim4", ".*ANYMORE", changeNullFn), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new RegexDimFilter("dim4", "a.*", changeNullFn), ImmutableList.<String>of());
}
use of io.druid.query.filter.RegexDimFilter in project druid by druid-io.
the class RegexFilterTest method testSingleValueStringColumnWithNulls.
@Test
public void testSingleValueStringColumnWithNulls() {
// RegexFilter always returns false for null row values.
assertFilterMatches(new RegexDimFilter("dim1", ".*", null), ImmutableList.of("1", "2", "3", "4", "5"));
assertFilterMatches(new RegexDimFilter("dim1", "10", null), ImmutableList.of("1"));
assertFilterMatches(new RegexDimFilter("dim1", "2", null), ImmutableList.of("2"));
assertFilterMatches(new RegexDimFilter("dim1", "1", null), ImmutableList.of("1", "3"));
assertFilterMatches(new RegexDimFilter("dim1", ".*def", null), ImmutableList.of("4"));
assertFilterMatches(new RegexDimFilter("dim1", "abc", null), ImmutableList.of("5"));
assertFilterMatches(new RegexDimFilter("dim1", "ab.*", null), ImmutableList.<String>of("4", "5"));
}
Aggregations