Search in sources :

Example 21 with JavaScriptExtractionFn

use of io.druid.query.extraction.JavaScriptExtractionFn in project druid by druid-io.

the class SearchQueryRunnerTest method testSearchOnLongColumnWithExFn.

@Test
public void testSearchOnLongColumnWithExFn() {
    String jsFn = "function(str) { return 'super-' + str; }";
    ExtractionFn jsExtractionFn = new JavaScriptExtractionFn(jsFn, false, JavaScriptConfig.getEnabledInstance());
    SearchQuery searchQuery = Druids.newSearchQueryBuilder().dimensions(new ExtractionDimensionSpec(Column.TIME_COLUMN_NAME, Column.TIME_COLUMN_NAME, jsExtractionFn)).dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).query("1297123200000").build();
    List<SearchHit> expectedHits = Lists.newLinkedList();
    expectedHits.add(new SearchHit(Column.TIME_COLUMN_NAME, "super-1297123200000", 13));
    checkSearchQuery(searchQuery, expectedHits);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) LookupExtractionFn(io.druid.query.lookup.LookupExtractionFn) ExtractionFn(io.druid.query.extraction.ExtractionFn) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) TimeFormatExtractionFn(io.druid.query.extraction.TimeFormatExtractionFn) SearchHit(io.druid.query.search.search.SearchHit) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Example 22 with JavaScriptExtractionFn

use of io.druid.query.extraction.JavaScriptExtractionFn in project druid by druid-io.

the class SearchQueryRunnerTest method testSearchOnFloatColumnWithExFn.

@Test
public void testSearchOnFloatColumnWithExFn() {
    String jsFn = "function(str) { return 'super-' + str; }";
    ExtractionFn jsExtractionFn = new JavaScriptExtractionFn(jsFn, false, JavaScriptConfig.getEnabledInstance());
    SearchQuery searchQuery = Druids.newSearchQueryBuilder().dimensions(new ExtractionDimensionSpec(QueryRunnerTestHelper.indexMetric, QueryRunnerTestHelper.indexMetric, jsExtractionFn)).dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).query("100.7").build();
    List<SearchHit> expectedHits = Lists.newLinkedList();
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.indexMetric, "super-100.7060546875", 1));
    expectedHits.add(new SearchHit(QueryRunnerTestHelper.indexMetric, "super-100.77559661865234", 1));
    checkSearchQuery(searchQuery, expectedHits);
}
Also used : SearchQuery(io.druid.query.search.search.SearchQuery) LookupExtractionFn(io.druid.query.lookup.LookupExtractionFn) ExtractionFn(io.druid.query.extraction.ExtractionFn) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) TimeFormatExtractionFn(io.druid.query.extraction.TimeFormatExtractionFn) SearchHit(io.druid.query.search.search.SearchHit) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) ExtractionDimensionSpec(io.druid.query.dimension.ExtractionDimensionSpec) Test(org.junit.Test)

Aggregations

JavaScriptExtractionFn (io.druid.query.extraction.JavaScriptExtractionFn)22 Test (org.junit.Test)22 ExtractionFn (io.druid.query.extraction.ExtractionFn)21 LookupExtractionFn (io.druid.query.lookup.LookupExtractionFn)17 TimeFormatExtractionFn (io.druid.query.extraction.TimeFormatExtractionFn)15 ExtractionDimensionSpec (io.druid.query.dimension.ExtractionDimensionSpec)14 DimExtractionFn (io.druid.query.extraction.DimExtractionFn)11 RegexDimExtractionFn (io.druid.query.extraction.RegexDimExtractionFn)11 StrlenExtractionFn (io.druid.query.extraction.StrlenExtractionFn)11 Result (io.druid.query.Result)8 DateTime (org.joda.time.DateTime)8 CascadeExtractionFn (io.druid.query.extraction.CascadeExtractionFn)6 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)6 Row (io.druid.data.input.Row)5 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)5 PostAggregator (io.druid.query.aggregation.PostAggregator)5 HyperUniqueFinalizingPostAggregator (io.druid.query.aggregation.hyperloglog.HyperUniqueFinalizingPostAggregator)5 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)5 DoubleMaxAggregatorFactory (io.druid.query.aggregation.DoubleMaxAggregatorFactory)4 DoubleMinAggregatorFactory (io.druid.query.aggregation.DoubleMinAggregatorFactory)4