Search in sources :

Example 21 with DimFilter

use of io.druid.query.filter.DimFilter in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesWithMultiDimFilterAndOr.

@Test
public void testTimeseriesWithMultiDimFilterAndOr() {
    AndDimFilter andDimFilter = Druids.newAndDimFilterBuilder().fields(Arrays.<DimFilter>asList(Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.marketDimension).value("spot").build(), Druids.newOrDimFilterBuilder().fields(QueryRunnerTestHelper.qualityDimension, "automotive", "business").build())).build();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).filters(andDimFilter).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 2L, "index", 254.4554443359375D, "addRowsIndexConstant", 257.4554443359375D, "uniques", QueryRunnerTestHelper.UNIQUES_2))), new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 2L, "index", 260.4129638671875D, "addRowsIndexConstant", 263.4129638671875D, "uniques", QueryRunnerTestHelper.UNIQUES_2))));
    Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(runner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults, results);
}
Also used : AndDimFilter(io.druid.query.filter.AndDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) NotDimFilter(io.druid.query.filter.NotDimFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 22 with DimFilter

use of io.druid.query.filter.DimFilter in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesWithNonExistentFilterAndMultiDim.

@Test
public void testTimeseriesWithNonExistentFilterAndMultiDim() {
    AndDimFilter andDimFilter = Druids.newAndDimFilterBuilder().fields(Arrays.<DimFilter>asList(Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.marketDimension).value("billy").build(), Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.qualityDimension).value("business").build())).build();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).filters(andDimFilter).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 0L, "index", 0.0, "addRowsIndexConstant", 1.0, "uniques", 0.0))), new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 0L, "index", 0.0, "addRowsIndexConstant", 1.0, "uniques", 0.0))));
    Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(runner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults, results);
}
Also used : AndDimFilter(io.druid.query.filter.AndDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) NotDimFilter(io.druid.query.filter.NotDimFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 23 with DimFilter

use of io.druid.query.filter.DimFilter in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesWithOtherMultiDimFilter.

@Test
public void testTimeseriesWithOtherMultiDimFilter() {
    AndDimFilter andDimFilter = Druids.newAndDimFilterBuilder().fields(Arrays.<DimFilter>asList(Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.marketDimension).value("spot").build(), Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.qualityDimension).value("business").build())).build();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).filters(andDimFilter).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 1L, "index", new Float(118.570340).doubleValue(), "addRowsIndexConstant", new Float(120.570340).doubleValue(), "uniques", QueryRunnerTestHelper.UNIQUES_1))), new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 1L, "index", new Float(112.987027).doubleValue(), "addRowsIndexConstant", new Float(114.987027).doubleValue(), "uniques", QueryRunnerTestHelper.UNIQUES_1))));
    Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(runner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults, results);
}
Also used : AndDimFilter(io.druid.query.filter.AndDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) NotDimFilter(io.druid.query.filter.NotDimFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 24 with DimFilter

use of io.druid.query.filter.DimFilter in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesWithMultiDimFilter.

@Test
public void testTimeseriesWithMultiDimFilter() {
    AndDimFilter andDimFilter = Druids.newAndDimFilterBuilder().fields(Arrays.<DimFilter>asList(Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.marketDimension).value("spot").build(), Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.qualityDimension).value("automotive").build())).build();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).filters(andDimFilter).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 1L, "index", new Float(135.885094).doubleValue(), "addRowsIndexConstant", new Float(137.885094).doubleValue(), "uniques", QueryRunnerTestHelper.UNIQUES_1))), new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 1L, "index", new Float(147.425935).doubleValue(), "addRowsIndexConstant", new Float(149.425935).doubleValue(), "uniques", QueryRunnerTestHelper.UNIQUES_1))));
    Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(runner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults, results);
}
Also used : AndDimFilter(io.druid.query.filter.AndDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) NotDimFilter(io.druid.query.filter.NotDimFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Example 25 with DimFilter

use of io.druid.query.filter.DimFilter in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesWithNonExistentFilterAndMultiDimAndOr.

@Test
public void testTimeseriesWithNonExistentFilterAndMultiDimAndOr() {
    AndDimFilter andDimFilter = Druids.newAndDimFilterBuilder().fields(Arrays.<DimFilter>asList(Druids.newSelectorDimFilterBuilder().dimension(QueryRunnerTestHelper.marketDimension).value("spot").build(), Druids.newOrDimFilterBuilder().fields(QueryRunnerTestHelper.qualityDimension, "automotive", "business", "billyblank").build())).build();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.dayGran).filters(andDimFilter).intervals(QueryRunnerTestHelper.firstToThird).aggregators(QueryRunnerTestHelper.commonAggregators).postAggregators(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant)).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(new DateTime("2011-04-01"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 2L, "index", 254.4554443359375D, "addRowsIndexConstant", 257.4554443359375D, "uniques", QueryRunnerTestHelper.UNIQUES_2))), new Result<>(new DateTime("2011-04-02"), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 2L, "index", 260.4129638671875D, "addRowsIndexConstant", 263.4129638671875D, "uniques", QueryRunnerTestHelper.UNIQUES_2))));
    Iterable<Result<TimeseriesResultValue>> results = Sequences.toList(runner.run(query, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults, results);
}
Also used : AndDimFilter(io.druid.query.filter.AndDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) NotDimFilter(io.druid.query.filter.NotDimFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test)

Aggregations

DimFilter (io.druid.query.filter.DimFilter)56 AndDimFilter (io.druid.query.filter.AndDimFilter)45 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)39 Test (org.junit.Test)32 BoundDimFilter (io.druid.query.filter.BoundDimFilter)30 OrDimFilter (io.druid.query.filter.OrDimFilter)27 InDimFilter (io.druid.query.filter.InDimFilter)24 NotDimFilter (io.druid.query.filter.NotDimFilter)19 RegexDimFilter (io.druid.query.filter.RegexDimFilter)18 Result (io.druid.query.Result)14 ExtractionDimFilter (io.druid.query.filter.ExtractionDimFilter)14 DateTime (org.joda.time.DateTime)14 JavaScriptDimFilter (io.druid.query.filter.JavaScriptDimFilter)11 SearchQueryDimFilter (io.druid.query.filter.SearchQueryDimFilter)11 List (java.util.List)11 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)10 ArrayList (java.util.ArrayList)9 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)8 DimensionSpec (io.druid.query.dimension.DimensionSpec)7 Row (io.druid.data.input.Row)6