Search in sources :

Example 36 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class VectorizedVirtualColumnTest method testTimeseries.

private void testTimeseries(ColumnCapabilities capabilities) {
    testTimeseries(capabilities, CONTEXT_VECTORIZE_FORCE, true);
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().intervals("2000/2030").dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(Granularities.ALL).virtualColumns(new AlwaysTwoVectorizedVirtualColumn(ALWAYS_TWO, capabilities)).aggregators(new AlwaysTwoCounterAggregatorFactory(COUNT, ALWAYS_TWO)).context(CONTEXT_VECTORIZE_FORCE).build();
    Sequence seq = timeseriesTestHelper.runQueryOnSegmentsObjs(segments, query);
    List<Result<TimeseriesResultValue>> expectedResults = ImmutableList.of(new Result<>(DateTimes.of("2011-01-12T00:00:00.000Z"), new TimeseriesResultValue(ImmutableMap.of(COUNT, getCount(capabilities)))));
    TestHelper.assertExpectedObjects(expectedResults, seq.toList(), "failed");
}
Also used : TimeseriesResultValue(org.apache.druid.query.timeseries.TimeseriesResultValue) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) Sequence(org.apache.druid.java.util.common.guava.Sequence) Result(org.apache.druid.query.Result)

Example 37 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class VectorizedVirtualColumnTest method testTimeseries.

private void testTimeseries(ColumnCapabilities capabilities, Map<String, Object> context, boolean canVectorize) {
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().intervals("2000/2030").dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(Granularities.ALL).virtualColumns(new AlwaysTwoVectorizedVirtualColumn(ALWAYS_TWO, capabilities, canVectorize)).aggregators(new AlwaysTwoCounterAggregatorFactory(COUNT, ALWAYS_TWO)).context(context).build();
    Sequence seq = timeseriesTestHelper.runQueryOnSegmentsObjs(segments, query);
    List<Result<TimeseriesResultValue>> expectedResults = ImmutableList.of(new Result<>(DateTimes.of("2011-01-12T00:00:00.000Z"), new TimeseriesResultValue(ImmutableMap.of(COUNT, getCount(capabilities)))));
    TestHelper.assertExpectedObjects(expectedResults, seq.toList(), "failed");
}
Also used : TimeseriesResultValue(org.apache.druid.query.timeseries.TimeseriesResultValue) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) Sequence(org.apache.druid.java.util.common.guava.Sequence) Result(org.apache.druid.query.Result)

Example 38 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class SchemalessTestSimpleTest method testFullOnTimeseries.

@Test
public void testFullOnTimeseries() {
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(dataSource).granularity(ALL_GRAN).intervals(fullOnInterval).aggregators(Lists.newArrayList(Iterables.concat(commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(addRowsIndexConstant).build();
    List<Result<TimeseriesResultValue>> expectedResults = Collections.singletonList(new Result(DateTimes.of("2011-01-12T00:00:00.000Z"), new TimeseriesResultValue(ImmutableMap.<String, Object>builder().put("rows", coalesceAbsentAndEmptyDims ? 10L : 11L).put("index", 900.0).put("addRowsIndexConstant", coalesceAbsentAndEmptyDims ? 911.0 : 912.0).put("uniques", 2.000977198748901D).put("maxIndex", 100.0).put("minIndex", NullHandling.replaceWithDefault() ? 0.0 : 100.0).build())));
    QueryRunner runner = TestQueryRunners.makeTimeSeriesQueryRunner(segment);
    TestHelper.assertExpectedResults(expectedResults, runner.run(QueryPlus.wrap(query)));
}
Also used : TimeseriesResultValue(org.apache.druid.query.timeseries.TimeseriesResultValue) DoubleMaxAggregatorFactory(org.apache.druid.query.aggregation.DoubleMaxAggregatorFactory) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DoubleMinAggregatorFactory(org.apache.druid.query.aggregation.DoubleMinAggregatorFactory) QueryRunner(org.apache.druid.query.QueryRunner) Result(org.apache.druid.query.Result) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Example 39 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class SchemalessTestFullTest method testFullOnTimeseries.

private void testFullOnTimeseries(QueryRunner runner, List<Result<TimeseriesResultValue>> expectedResults, String failMsg) {
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(dataSource).granularity(ALL_GRAN).intervals(fullOnInterval).aggregators(Lists.newArrayList(Iterables.concat(commonAggregators, Lists.newArrayList(new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"))))).postAggregators(addRowsIndexConstant).build();
    failMsg += " timeseries ";
    Iterable<Result<TimeseriesResultValue>> actualResults = runner.run(QueryPlus.wrap(query)).toList();
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : DoubleMaxAggregatorFactory(org.apache.druid.query.aggregation.DoubleMaxAggregatorFactory) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) DoubleMinAggregatorFactory(org.apache.druid.query.aggregation.DoubleMinAggregatorFactory) Result(org.apache.druid.query.Result)

Example 40 with TimeseriesQuery

use of org.apache.druid.query.timeseries.TimeseriesQuery in project druid by druid-io.

the class TieredBrokerHostSelectorTest method testBasicSelect.

@Test
public void testBasicSelect() {
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("test").granularity("all").aggregators(Collections.singletonList(new CountAggregatorFactory("rows"))).intervals(Collections.singletonList(Intervals.of("2011-08-31/2011-09-01"))).build();
    Pair<String, Server> p = brokerSelector.select(query);
    Assert.assertEquals("coldBroker", p.lhs);
    Assert.assertEquals("coldHost1:8080", p.rhs.getHost());
    p = brokerSelector.select(query);
    Assert.assertEquals("coldBroker", p.lhs);
    Assert.assertEquals("coldHost2:8080", p.rhs.getHost());
    p = brokerSelector.select(query);
    Assert.assertEquals("coldBroker", p.lhs);
    Assert.assertEquals("coldHost1:8080", p.rhs.getHost());
}
Also used : TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) DruidServer(org.apache.druid.client.DruidServer) Server(org.apache.druid.client.selector.Server) Test(org.junit.Test)

Aggregations

TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)130 Test (org.junit.Test)109 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)58 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)50 Result (org.apache.druid.query.Result)39 TimeseriesResultValue (org.apache.druid.query.timeseries.TimeseriesResultValue)35 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)29 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)25 QueryRunner (org.apache.druid.query.QueryRunner)22 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)21 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)17 Interval (org.joda.time.Interval)17 TimeseriesQueryEngine (org.apache.druid.query.timeseries.TimeseriesQueryEngine)15 TimeseriesQueryRunnerFactory (org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory)15 ArrayList (java.util.ArrayList)13 FinalizingFieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator)13 DateTime (org.joda.time.DateTime)12 Sequence (org.apache.druid.java.util.common.guava.Sequence)11 IOException (java.io.IOException)10 SpatialDimFilter (org.apache.druid.query.filter.SpatialDimFilter)9