use of io.druid.query.spec.LegacySegmentSpec in project druid by druid-io.
the class SelectQuerySpecTest method testPagingSpecFromNext.
@Test
public void testPagingSpecFromNext() throws Exception {
String baseQueryJson = "{\"queryType\":\"select\",\"dataSource\":{\"type\":\"table\",\"name\":\"testing\"}," + "\"intervals\":{\"type\":\"LegacySegmentSpec\",\"intervals\":[\"2011-01-12T00:00:00.000Z/2011-01-14T00:00:00.000Z\"]}," + "\"descending\":true," + "\"filter\":null," + "\"granularity\":{\"type\":\"all\"}," + "\"dimensions\":" + "[{\"type\":\"default\",\"dimension\":\"market\",\"outputName\":\"market\",\"outputType\":\"STRING\"}," + "{\"type\":\"default\",\"dimension\":\"quality\",\"outputName\":\"quality\",\"outputType\":\"STRING\"}]," + "\"metrics\":[\"index\"]," + "\"virtualColumns\":[],";
String withNull = baseQueryJson + "\"pagingSpec\":{\"pagingIdentifiers\":{},\"threshold\":3,\"fromNext\":null}," + "\"context\":null}";
String withFalse = baseQueryJson + "\"pagingSpec\":{\"pagingIdentifiers\":{},\"threshold\":3,\"fromNext\":false}," + "\"context\":null}";
String withTrue = baseQueryJson + "\"pagingSpec\":{\"pagingIdentifiers\":{},\"threshold\":3,\"fromNext\":true}," + "\"context\":null}";
SelectQuery queryWithNull = new SelectQuery(new TableDataSource(QueryRunnerTestHelper.dataSource), new LegacySegmentSpec(new Interval("2011-01-12/2011-01-14")), true, null, QueryRunnerTestHelper.allGran, DefaultDimensionSpec.toSpec(Arrays.<String>asList("market", "quality")), Arrays.<String>asList("index"), null, new PagingSpec(null, 3, null), null);
SelectQuery queryWithFalse = queryWithNull.withPagingSpec(new PagingSpec(null, 3, false));
SelectQuery queryWithTrue = queryWithNull.withPagingSpec(new PagingSpec(null, 3, true));
String actualWithNull = objectMapper.writeValueAsString(queryWithNull);
Assert.assertEquals(withTrue, actualWithNull);
String actualWithFalse = objectMapper.writeValueAsString(queryWithFalse);
Assert.assertEquals(withFalse, actualWithFalse);
String actualWithTrue = objectMapper.writeValueAsString(queryWithTrue);
Assert.assertEquals(withTrue, actualWithTrue);
Assert.assertEquals(queryWithNull, objectMapper.readValue(actualWithNull, SelectQuery.class));
Assert.assertEquals(queryWithFalse, objectMapper.readValue(actualWithFalse, SelectQuery.class));
Assert.assertEquals(queryWithTrue, objectMapper.readValue(actualWithTrue, SelectQuery.class));
}
use of io.druid.query.spec.LegacySegmentSpec in project druid by druid-io.
the class MultiValuedDimensionTest method testGroupByWithDimFilterAndWithFilteredDimSpec.
@Test
public void testGroupByWithDimFilterAndWithFilteredDimSpec() throws Exception {
GroupByQuery query = GroupByQuery.builder().setDataSource("xx").setQuerySegmentSpec(new LegacySegmentSpec("1970/3000")).setGranularity(Granularities.ALL).setDimensions(Lists.<DimensionSpec>newArrayList(new RegexFilteredDimensionSpec(new DefaultDimensionSpec("tags", "tags"), "t3"))).setAggregatorSpecs(Arrays.asList(new AggregatorFactory[] { new CountAggregatorFactory("count") })).setDimFilter(new SelectorDimFilter("tags", "t3", null)).build();
Sequence<Row> result = helper.runQueryOnSegmentsObjs(ImmutableList.<Segment>of(new QueryableIndexSegment("sid1", queryableIndex), new IncrementalIndexSegment(incrementalIndex, "sid2")), query);
List<Row> expectedResults = Arrays.asList(GroupByQueryRunnerTestHelper.createExpectedRow("1970-01-01T00:00:00.000Z", "tags", "t3", "count", 4L));
TestHelper.assertExpectedObjects(expectedResults, Sequences.toList(result, new ArrayList<Row>()), "");
}
Aggregations