Search in sources :

Example 41 with PeriodGranularity

use of io.druid.java.util.common.granularity.PeriodGranularity in project druid by druid-io.

the class TimeseriesQueryRunnerTest method testTimeseriesGranularityNotAlignedOnSegmentBoundariesWithFilter.

@Test
public void testTimeseriesGranularityNotAlignedOnSegmentBoundariesWithFilter() {
    TimeseriesQuery query1 = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).filters(QueryRunnerTestHelper.marketDimension, "spot", "upfront", "total_market").granularity(new PeriodGranularity(new Period("P7D"), null, DateTimeZone.forID("America/Los_Angeles"))).intervals(Arrays.asList(new Interval("2011-01-12T00:00:00.000-08:00/2011-01-20T00:00:00.000-08:00"))).aggregators(Arrays.<AggregatorFactory>asList(QueryRunnerTestHelper.rowsCount, new LongSumAggregatorFactory("idx", "index"))).descending(descending).build();
    List<Result<TimeseriesResultValue>> expectedResults1 = Arrays.asList(new Result<>(new DateTime("2011-01-06T00:00:00.000-08:00", DateTimeZone.forID("America/Los_Angeles")), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 13L, "idx", 6071L))), new Result<>(new DateTime("2011-01-13T00:00:00.000-08:00", DateTimeZone.forID("America/Los_Angeles")), new TimeseriesResultValue(ImmutableMap.<String, Object>of("rows", 91L, "idx", 33382L))));
    Iterable<Result<TimeseriesResultValue>> results1 = Sequences.toList(runner.run(query1, CONTEXT), Lists.<Result<TimeseriesResultValue>>newArrayList());
    assertExpectedResults(expectedResults1, results1);
}
Also used : PeriodGranularity(io.druid.java.util.common.granularity.PeriodGranularity) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) Period(org.joda.time.Period) DateTime(org.joda.time.DateTime) Interval(org.joda.time.Interval) Result(io.druid.query.Result) Test(org.junit.Test)

Aggregations

PeriodGranularity (io.druid.java.util.common.granularity.PeriodGranularity)41 Period (org.joda.time.Period)39 Test (org.junit.Test)36 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)26 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)20 DateTime (org.joda.time.DateTime)19 Row (io.druid.data.input.Row)18 Interval (org.joda.time.Interval)18 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)9 QueryRunner (io.druid.query.QueryRunner)9 Result (io.druid.query.Result)9 ExtractionDimensionSpec (io.druid.query.dimension.ExtractionDimensionSpec)9 DimensionSpec (io.druid.query.dimension.DimensionSpec)8 ListFilteredDimensionSpec (io.druid.query.dimension.ListFilteredDimensionSpec)7 RegexFilteredDimensionSpec (io.druid.query.dimension.RegexFilteredDimensionSpec)7 DimFilterHavingSpec (io.druid.query.groupby.having.DimFilterHavingSpec)7 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)6 GreaterThanHavingSpec (io.druid.query.groupby.having.GreaterThanHavingSpec)6 OrHavingSpec (io.druid.query.groupby.having.OrHavingSpec)6 MergeSequence (io.druid.java.util.common.guava.MergeSequence)5