Search in sources :

Example 1 with LegacyDimensionSpec

use of io.druid.query.dimension.LegacyDimensionSpec in project druid by druid-io.

the class SearchQueryTest method testSerDe.

@Test
public void testSerDe() throws IOException {
    Query query = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).dimensions(new LegacyDimensionSpec(QueryRunnerTestHelper.qualityDimension)).query("a").build();
    final String json = "{\"queryType\":\"search\",\"dataSource\":{\"type\":\"table\",\"name\":\"testing\"},\"filter\":null,\"granularity\":{\"type\":\"all\"},\"limit\":1000,\"intervals\":{\"type\":\"intervals\",\"intervals\":[\"1970-01-01T00:00:00.000Z/2020-01-01T00:00:00.000Z\"]},\"searchDimensions\":[\"" + QueryRunnerTestHelper.qualityDimension + "\"],\"query\":{\"type\":\"insensitive_contains\",\"value\":\"a\"},\"sort\":{\"type\":\"lexicographic\"},\"context\":null}";
    final Query serdeQuery = jsonMapper.readValue(json, Query.class);
    Assert.assertEquals(query.toString(), serdeQuery.toString());
    Assert.assertEquals(query, serdeQuery);
    final String json2 = "{\"queryType\":\"search\",\"dataSource\":{\"type\":\"table\",\"name\":\"testing\"},\"filter\":null,\"granularity\":{\"type\":\"all\"},\"limit\":1000,\"intervals\":{\"type\":\"intervals\",\"intervals\":[\"1970-01-01T00:00:00.000Z/2020-01-01T00:00:00.000Z\"]},\"searchDimensions\":[\"quality\"],\"query\":{\"type\":\"insensitive_contains\",\"value\":\"a\"},\"sort\":{\"type\":\"lexicographic\"},\"context\":null}";
    final Query serdeQuery2 = jsonMapper.readValue(json2, Query.class);
    Assert.assertEquals(query.toString(), serdeQuery2.toString());
    Assert.assertEquals(query, serdeQuery2);
}
Also used : Query(io.druid.query.Query) LegacyDimensionSpec(io.druid.query.dimension.LegacyDimensionSpec) Test(org.junit.Test)

Aggregations

Query (io.druid.query.Query)1 LegacyDimensionSpec (io.druid.query.dimension.LegacyDimensionSpec)1 Test (org.junit.Test)1