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");
}
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");
}
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)));
}
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);
}
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());
}
Aggregations