use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class JoinFilterAnalyzerTest method test_filterPushDown_factToRegionToCountryLeftFilterNormalizedAlreadyPushDownVariety.
@Test
public void test_filterPushDown_factToRegionToCountryLeftFilterNormalizedAlreadyPushDownVariety() {
Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#fr.wikipedia"), new BoundFilter(new BoundDimFilter("page", "Les Argonautes", "Les Argonautes", false, false, null, null, null)), new SelectorFilter("rtc.countryName", "Canada"), new BoundFilter(new BoundDimFilter("rtc.countryName", "Canada", "Canada", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("user", "24.122.168.111", "24.122.168.111", false, false, null, null, null)))), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("r1.regionName", "Quebec", "Quebec", false, false, null, null, null))))));
List<JoinableClause> joinableClauses = ImmutableList.of(factToRegion(JoinType.LEFT), regionToCountry(JoinType.LEFT));
JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_REGION_PREFIX + "regionName", REGION_TO_COUNTRY_PREFIX + "countryName"), ImmutableList.of(new Object[] { "Les Argonautes", "Quebec", "Canada" }));
JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#fr.wikipedia"), new BoundFilter(new BoundDimFilter("page", "Les Argonautes", "Les Argonautes", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("user", "24.122.168.111", "24.122.168.111", false, false, null, null, null)))), new InDimFilter("countryIsoCode", ImmutableSet.of("CA"), null, null).toFilter())), new AndFilter(ImmutableList.of(new SelectorFilter("rtc.countryName", "Canada"), new BoundFilter(new BoundDimFilter("rtc.countryName", "Canada", "Canada", false, false, null, null, null)), new OrFilter(ImmutableList.of(new SelectorFilter("namespace", "main"), new BoundFilter(new BoundDimFilter("r1.regionName", "Quebec", "Quebec", false, false, null, null, null)))))), ImmutableSet.of());
JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class TopNQueryRunnerTest method testTopNWithNonBitmapFilter.
/**
* Regression test for https://github.com/apache/druid/issues/5132
*/
@Test
public void testTopNWithNonBitmapFilter() {
TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(QueryRunnerTestHelper.ALL_GRAN).filters(new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", String.valueOf(Long.MAX_VALUE), true, true, false, null, StringComparators.NUMERIC)).dimension(QueryRunnerTestHelper.MARKET_DIMENSION).metric("count").threshold(4).intervals(QueryRunnerTestHelper.FIRST_TO_THIRD).aggregators(new DoubleSumAggregatorFactory("count", "qualityDouble")).build();
// Don't check results, just the fact that the query could complete
Assert.assertNotNull(runWithMerge(query).toList());
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class TimeFilteringTest method testTimeFilterWithExtractionFn.
@Test
public void testTimeFilterWithExtractionFn() {
final Map<String, String> stringMap = new HashMap<>();
stringMap.put("0", "Monday");
stringMap.put("1", "Tuesday");
stringMap.put("2", "Wednesday");
stringMap.put("3", "Thursday");
stringMap.put("4", "Friday");
stringMap.put("5", "Saturday");
LookupExtractor mapExtractor = new MapLookupExtractor(stringMap, false);
LookupExtractionFn exfn = new LookupExtractionFn(mapExtractor, false, "UNKNOWN", false, true);
assertFilterMatches(new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Monday", exfn), ImmutableList.of("0"));
assertFilterMatches(new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Notaday", exfn), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Fridax", "Fridaz", false, false, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of("4"));
assertFilterMatches(new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "Friday", "Friday", true, true, null, exfn, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList("Caturday", "Saturday", "Tuesday"), exfn), ImmutableList.of("1", "5"));
// test InFilter HashSet implementation
List<String> bigList = Arrays.asList("Saturday", "Tuesday", "Caturday", "Xanaday", "Vojuday", "Gribaday", "Kipoday", "Dheferday", "Fakeday", "Qeearaday", "Hello", "World", "1", "2", "3", "4", "5", "6", "7");
assertFilterMatches(new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, bigList, exfn), ImmutableList.of("1", "5"));
String jsFn = "function(x) { return(x === 'Wednesday' || x === 'Thursday') }";
assertFilterMatchesSkipVectorize(new JavaScriptDimFilter(ColumnHolder.TIME_COLUMN_NAME, jsFn, exfn, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("2", "3"));
assertFilterMatches(new RegexDimFilter(ColumnHolder.TIME_COLUMN_NAME, ".*day", exfn), ImmutableList.of("0", "1", "2", "3", "4", "5"));
assertFilterMatches(new SearchQueryDimFilter(ColumnHolder.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("s", true), exfn), ImmutableList.of("1", "2", "3"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class TimeFilteringTest method testTimeFilterAsLong.
@Test
public void testTimeFilterAsLong() {
assertFilterMatches(new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", null), ImmutableList.of("0"));
assertFilterMatches(new SelectorDimFilter(ColumnHolder.TIME_COLUMN_NAME, "9000", null), ImmutableList.of());
assertFilterMatches(new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", "4", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of("0", "1", "2", "3", "4"));
assertFilterMatches(new BoundDimFilter(ColumnHolder.TIME_COLUMN_NAME, "0", "4", true, true, null, null, StringComparators.NUMERIC), ImmutableList.of("1", "2", "3"));
assertFilterMatches(new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, Arrays.asList("2", "4", "8"), null), ImmutableList.of("2", "4"));
// cross the hashing threshold to test hashset implementation, filter on even values
List<String> infilterValues = new ArrayList<>(NUM_FILTER_VALUES);
for (int i = 0; i < NUM_FILTER_VALUES; i++) {
infilterValues.add(String.valueOf(i * 2));
}
assertFilterMatches(new InDimFilter(ColumnHolder.TIME_COLUMN_NAME, infilterValues, null), ImmutableList.of("0", "2", "4"));
String jsFn = "function(x) { return(x === 3 || x === 5) }";
assertFilterMatchesSkipVectorize(new JavaScriptDimFilter(ColumnHolder.TIME_COLUMN_NAME, jsFn, null, JavaScriptConfig.getEnabledInstance()), ImmutableList.of("3", "5"));
assertFilterMatches(new RegexDimFilter(ColumnHolder.TIME_COLUMN_NAME, "4", null), ImmutableList.of("4"));
assertFilterMatches(new SearchQueryDimFilter(ColumnHolder.TIME_COLUMN_NAME, new ContainsSearchQuerySpec("2", true), null), ImmutableList.of("2"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class LongFilteringTest method testMultithreaded.
@Test
public void testMultithreaded() {
assertFilterMatchesMultithreaded(new SelectorDimFilter(LONG_COLUMN, "3", null), ImmutableList.of("3"));
assertFilterMatchesMultithreaded(new InDimFilter(LONG_COLUMN, Arrays.asList("2", "4", "8"), null), ImmutableList.of("2", "4"));
// cross the hashing threshold to test hashset implementation, filter on even values
List<String> infilterValues = new ArrayList<>(NUM_FILTER_VALUES);
for (int i = 0; i < NUM_FILTER_VALUES; i++) {
infilterValues.add(String.valueOf(i * 2));
}
assertFilterMatchesMultithreaded(new InDimFilter(LONG_COLUMN, infilterValues, null), ImmutableList.of("2", "4", "6"));
assertFilterMatches(new BoundDimFilter(LONG_COLUMN, "2", "5", false, false, null, null, StringComparators.NUMERIC), ImmutableList.of("2", "3", "4", "5"));
}
Aggregations