Search in sources :

Example 11 with SearchQuery

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

the class SchemalessTestFullTest method testFilteredSearch.

private void testFilteredSearch(QueryRunner runner, List<Result<SearchResultValue>> expectedResults, String failMsg) {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(ALL_GRAN).filters(marketDimension, "spot").intervals(fullOnInterval).query("a").build();
    failMsg += " filtered search ";
    Iterable<Result<SearchResultValue>> actualResults = runner.run(QueryPlus.wrap(query)).toList();
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : SearchQuery(org.apache.druid.query.search.SearchQuery) Result(org.apache.druid.query.Result)

Example 12 with SearchQuery

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

the class SchemalessTestFullTest method testFullOnSearch.

private void testFullOnSearch(QueryRunner runner, List<Result<SearchResultValue>> expectedResults, String failMsg) {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(ALL_GRAN).intervals(fullOnInterval).query("a").build();
    failMsg += " search ";
    Iterable<Result<SearchResultValue>> actualResults = runner.run(QueryPlus.wrap(query)).toList();
    TestHelper.assertExpectedResults(expectedResults, actualResults, failMsg);
}
Also used : SearchQuery(org.apache.druid.query.search.SearchQuery) Result(org.apache.druid.query.Result)

Example 13 with SearchQuery

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

the class ServerManagerTest method testGetQueryRunnerForSegmentsWhenTimelineIsMissingReportingMissingSegments.

@Test
public void testGetQueryRunnerForSegmentsWhenTimelineIsMissingReportingMissingSegments() {
    final Interval interval = Intervals.of("0000-01-01/P1D");
    final SearchQuery query = searchQuery("unknown_datasource", 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 14 with SearchQuery

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

the class ServerManagerTest method testGetQueryRunnerForSegmentsWhenTimelinePartitionChunkIsMissingReportingMissingSegments.

@Test
public void testGetQueryRunnerForSegmentsWhenTimelinePartitionChunkIsMissingReportingMissingSegments() {
    final Interval interval = Intervals.of("P1d/2011-04-01");
    final int unknownPartitionId = 1000;
    final SearchQuery query = searchQuery("test", interval, Granularities.ALL);
    final List<SegmentDescriptor> unknownSegments = Collections.singletonList(new SegmentDescriptor(interval, "1", unknownPartitionId));
    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 15 with SearchQuery

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

the class ServerManagerTest method testGetQueryRunnerForSegmentsWhenSegmentIsClosedReportingMissingSegments.

@Test
public void testGetQueryRunnerForSegmentsWhenSegmentIsClosedReportingMissingSegments() {
    final Interval interval = Intervals.of("P1d/2011-04-01");
    final SearchQuery query = searchQuery("test", interval, Granularities.ALL);
    final Optional<VersionedIntervalTimeline<String, ReferenceCountingSegment>> maybeTimeline = segmentManager.getTimeline(DataSourceAnalysis.forDataSource(query.getDataSource()));
    Assert.assertTrue(maybeTimeline.isPresent());
    final List<TimelineObjectHolder<String, ReferenceCountingSegment>> holders = maybeTimeline.get().lookup(interval);
    final List<SegmentDescriptor> closedSegments = new ArrayList<>();
    for (TimelineObjectHolder<String, ReferenceCountingSegment> holder : holders) {
        for (PartitionChunk<ReferenceCountingSegment> chunk : holder.getObject()) {
            final ReferenceCountingSegment segment = chunk.getObject();
            Assert.assertNotNull(segment.getId());
            closedSegments.add(new SegmentDescriptor(segment.getDataInterval(), segment.getVersion(), segment.getId().getPartitionNum()));
            segment.close();
        }
    }
    final QueryRunner<Result<SearchResultValue>> queryRunner = serverManager.getQueryRunnerForSegments(query, closedSegments);
    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(closedSegments, responseContext.getMissingSegments());
}
Also used : SearchQuery(org.apache.druid.query.search.SearchQuery) ReferenceCountingSegment(org.apache.druid.segment.ReferenceCountingSegment) ArrayList(java.util.ArrayList) Result(org.apache.druid.query.Result) TimelineObjectHolder(org.apache.druid.timeline.TimelineObjectHolder) SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) DefaultResponseContext(org.apache.druid.query.context.DefaultResponseContext) ResponseContext(org.apache.druid.query.context.ResponseContext) VersionedIntervalTimeline(org.apache.druid.timeline.VersionedIntervalTimeline) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

SearchQuery (org.apache.druid.query.search.SearchQuery)22 Result (org.apache.druid.query.Result)18 Interval (org.joda.time.Interval)14 Test (org.junit.Test)12 ResponseContext (org.apache.druid.query.context.ResponseContext)10 SegmentDescriptor (org.apache.druid.query.SegmentDescriptor)8 DefaultResponseContext (org.apache.druid.query.context.DefaultResponseContext)8 QueryRunner (org.apache.druid.query.QueryRunner)6 SearchResultValue (org.apache.druid.query.search.SearchResultValue)6 ArrayList (java.util.ArrayList)4 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)4 Query (org.apache.druid.query.Query)4 Function (com.google.common.base.Function)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 HashFunction (com.google.common.hash.HashFunction)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2