Search in sources :

Example 91 with Result

use of org.apache.druid.query.Result 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 92 with Result

use of org.apache.druid.query.Result 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 93 with Result

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

the class DummyStringVirtualColumnTest method testTopN.

private void testTopN(List<Segment> segments, boolean enableRowBasedMethods, boolean enableColumnBasedMethods) {
    TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(Granularities.ALL).dimension(VSTRING_DIM).metric(COUNT).threshold(1).aggregators(new CountAggregatorFactory(COUNT)).virtualColumns(new DummyStringVirtualColumn(QueryRunnerTestHelper.MARKET_DIMENSION, VSTRING_DIM, enableRowBasedMethods, enableColumnBasedMethods, false, true)).intervals("2000/2030").build();
    List rows = topNTestHelper.runQueryOnSegmentsObjs(segments, query).toList();
    List<Result<TopNResultValue>> expectedRows = Collections.singletonList(new Result<>(DateTimes.of("2011-01-12T00:00:00.000Z"), new TopNResultValue(Collections.<Map<String, Object>>singletonList(ImmutableMap.<String, Object>builder().put(COUNT, 1674L).put(VSTRING_DIM, "spot").build()))));
    TestHelper.assertExpectedResults(expectedRows, (List<Result<TopNResultValue>>) rows, "failed");
}
Also used : TopNQueryBuilder(org.apache.druid.query.topn.TopNQueryBuilder) TopNResultValue(org.apache.druid.query.topn.TopNResultValue) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) TopNQuery(org.apache.druid.query.topn.TopNQuery) List(java.util.List) Result(org.apache.druid.query.Result)

Example 94 with Result

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

the class ServerManagerTest method testGetQueryRunnerForSegmentsWhenTimelineEntryIsMissingReportingMissingSegments.

@Test
public void testGetQueryRunnerForSegmentsWhenTimelineEntryIsMissingReportingMissingSegments() {
    final Interval interval = Intervals.of("P1d/2011-04-01");
    final SearchQuery query = searchQuery("test", interval, Granularities.ALL);
    final List<SegmentDescriptor> unknownSegments = Collections.singletonList(new SegmentDescriptor(interval, "unknown_version", 0));
    final QueryRunner<Result<SearchResultValue>> queryRunner = serverManager.getQueryRunnerForSegments(query, unknownSegments);
    final ResponseContext responseContext = DefaultResponseContext.createEmpty();
    final List<Result<SearchResultValue>> results = queryRunner.run(QueryPlus.wrap(query), responseContext).toList();
    Assert.assertTrue(results.isEmpty());
    Assert.assertNotNull(responseContext.getMissingSegments());
    Assert.assertEquals(unknownSegments, responseContext.getMissingSegments());
}
Also used : SearchQuery(org.apache.druid.query.search.SearchQuery) SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) DefaultResponseContext(org.apache.druid.query.context.DefaultResponseContext) ResponseContext(org.apache.druid.query.context.ResponseContext) Interval(org.joda.time.Interval) Result(org.apache.druid.query.Result) Test(org.junit.Test)

Example 95 with Result

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

the class ServerManagerTest method testGetQueryRunnerForIntervalsWhenTimelineIsMissingReturningNoopQueryRunner.

@Test
public void testGetQueryRunnerForIntervalsWhenTimelineIsMissingReturningNoopQueryRunner() {
    final Interval interval = Intervals.of("0000-01-01/P1D");
    final QueryRunner<Result<SearchResultValue>> queryRunner = serverManager.getQueryRunnerForIntervals(searchQuery("unknown_datasource", interval, Granularities.ALL), Collections.singletonList(interval));
    Assert.assertSame(NoopQueryRunner.class, queryRunner.getClass());
}
Also used : Interval(org.joda.time.Interval) Result(org.apache.druid.query.Result) Test(org.junit.Test)

Aggregations

Result (org.apache.druid.query.Result)252 Test (org.junit.Test)181 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)143 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)46 TimeseriesResultValue (org.apache.druid.query.timeseries.TimeseriesResultValue)44 TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)41 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)40 QueryRunner (org.apache.druid.query.QueryRunner)37 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)36 DoubleMaxAggregatorFactory (org.apache.druid.query.aggregation.DoubleMaxAggregatorFactory)34 DoubleMinAggregatorFactory (org.apache.druid.query.aggregation.DoubleMinAggregatorFactory)34 ArrayList (java.util.ArrayList)33 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)32 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)32 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)31 TopNResultValue (org.apache.druid.query.topn.TopNResultValue)28 DateTime (org.joda.time.DateTime)28 Benchmark (org.openjdk.jmh.annotations.Benchmark)28 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)28 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)28