Search in sources :

Example 6 with AndDimFilter

use of io.druid.query.filter.AndDimFilter 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 7 with AndDimFilter

use of io.druid.query.filter.AndDimFilter 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 8 with AndDimFilter

use of io.druid.query.filter.AndDimFilter 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 9 with AndDimFilter

use of io.druid.query.filter.AndDimFilter 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 10 with AndDimFilter

use of io.druid.query.filter.AndDimFilter 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

AndDimFilter (io.druid.query.filter.AndDimFilter)32 DimFilter (io.druid.query.filter.DimFilter)26 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)25 BoundDimFilter (io.druid.query.filter.BoundDimFilter)23 Test (org.junit.Test)21 NotDimFilter (io.druid.query.filter.NotDimFilter)15 OrDimFilter (io.druid.query.filter.OrDimFilter)15 InDimFilter (io.druid.query.filter.InDimFilter)13 Result (io.druid.query.Result)11 RegexDimFilter (io.druid.query.filter.RegexDimFilter)10 DateTime (org.joda.time.DateTime)9 List (java.util.List)8 ArrayList (java.util.ArrayList)6 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)4 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)4 Row (io.druid.data.input.Row)3 HashMap (java.util.HashMap)3 ImmutableList (com.google.common.collect.ImmutableList)2 PeriodGranularity (io.druid.java.util.common.granularity.PeriodGranularity)2 ExtractionDimFilter (io.druid.query.filter.ExtractionDimFilter)2