Search in sources :

Example 21 with SearchQueryDimFilter

use of org.apache.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class ExpressionsTest method testContainsAsFilter.

@Test
public void testContainsAsFilter() {
    testHelper.testFilter(ContainsOperatorConversion.caseSensitive().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("spacey"), testHelper.makeLiteral("there")), Collections.emptyList(), new SearchQueryDimFilter("spacey", new ContainsSearchQuerySpec("there", true), null), true);
    testHelper.testFilter(ContainsOperatorConversion.caseSensitive().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("spacey"), testHelper.makeLiteral("There")), Collections.emptyList(), new SearchQueryDimFilter("spacey", new ContainsSearchQuerySpec("There", true), null), false);
    testHelper.testFilter(ContainsOperatorConversion.caseInsensitive().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("spacey"), testHelper.makeLiteral("There")), Collections.emptyList(), new SearchQueryDimFilter("spacey", new ContainsSearchQuerySpec("There", false), null), true);
    testHelper.testFilter(ContainsOperatorConversion.caseSensitive().calciteOperator(), ImmutableList.of(testHelper.makeCall(SqlStdOperatorTable.CONCAT, testHelper.makeLiteral("what is"), testHelper.makeInputRef("spacey")), testHelper.makeLiteral("what")), ImmutableList.of(new ExpressionVirtualColumn("v0", "concat('what is',\"spacey\")", ColumnType.STRING, TestExprMacroTable.INSTANCE)), new SearchQueryDimFilter("v0", new ContainsSearchQuerySpec("what", true), null), true);
    testHelper.testFilter(ContainsOperatorConversion.caseSensitive().calciteOperator(), ImmutableList.of(testHelper.makeCall(SqlStdOperatorTable.CONCAT, testHelper.makeLiteral("what is"), testHelper.makeInputRef("spacey")), testHelper.makeLiteral("there")), ImmutableList.of(new ExpressionVirtualColumn("v0", "concat('what is',\"spacey\")", ColumnType.STRING, TestExprMacroTable.INSTANCE)), new SearchQueryDimFilter("v0", new ContainsSearchQuerySpec("there", true), null), true);
    testHelper.testFilter(ContainsOperatorConversion.caseInsensitive().calciteOperator(), ImmutableList.of(testHelper.makeCall(SqlStdOperatorTable.CONCAT, testHelper.makeLiteral("what is"), testHelper.makeInputRef("spacey")), testHelper.makeLiteral("What")), ImmutableList.of(new ExpressionVirtualColumn("v0", "concat('what is',\"spacey\")", ColumnType.STRING, TestExprMacroTable.INSTANCE)), new SearchQueryDimFilter("v0", new ContainsSearchQuerySpec("What", false), null), true);
    testHelper.testFilter(ContainsOperatorConversion.caseSensitive().calciteOperator(), ImmutableList.of(testHelper.makeInputRef("spacey"), testHelper.makeLiteral("")), Collections.emptyList(), new SearchQueryDimFilter("spacey", new ContainsSearchQuerySpec("", true), null), true);
}
Also used : ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) ContainsSearchQuerySpec(org.apache.druid.query.search.ContainsSearchQuerySpec) SearchQueryDimFilter(org.apache.druid.query.filter.SearchQueryDimFilter) Test(org.junit.Test)

Aggregations

SearchQueryDimFilter (org.apache.druid.query.filter.SearchQueryDimFilter)21 Test (org.junit.Test)16 ContainsSearchQuerySpec (org.apache.druid.query.search.ContainsSearchQuerySpec)14 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)12 RegexDimFilter (org.apache.druid.query.filter.RegexDimFilter)12 InDimFilter (org.apache.druid.query.filter.InDimFilter)11 JavaScriptDimFilter (org.apache.druid.query.filter.JavaScriptDimFilter)11 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)9 ArrayList (java.util.ArrayList)6 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)5 HashMap (java.util.HashMap)4 MapLookupExtractor (org.apache.druid.query.extraction.MapLookupExtractor)4 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)4 ExtractionFn (org.apache.druid.query.extraction.ExtractionFn)3 JavaScriptExtractionFn (org.apache.druid.query.extraction.JavaScriptExtractionFn)3 DimFilter (org.apache.druid.query.filter.DimFilter)3 LookupExtractor (org.apache.druid.query.lookup.LookupExtractor)3 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)2 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)2 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)2