From a0d3579a9276ec5e0216ca116414ab7f4497e126 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Thu, 11 Dec 2014 17:58:01 +0530 Subject: [PATCH] add docs + fix tests --- docs/content/DataSourceMetadataQuery.md | 31 +++++++++++++++++++ docs/content/toc.textile | 1 + .../DataSourceMetadataQueryTest.java | 8 ++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 docs/content/DataSourceMetadataQuery.md diff --git a/docs/content/DataSourceMetadataQuery.md b/docs/content/DataSourceMetadataQuery.md new file mode 100644 index 00000000000..4009cd1776c --- /dev/null +++ b/docs/content/DataSourceMetadataQuery.md @@ -0,0 +1,31 @@ +--- +layout: doc_page +--- +# Data Source Metadata Queries +Data Source Metadata queries return ingestion related information for a dataSource. It returns the timestamp of latest ingested event for the datasource. The grammar is: + +```json +{ + "queryType" : "dataSourceMetadata", + "dataSource": "sample_datasource", +} +``` + +There are 2 main parts to a Data Source Metadata query: + +|property|description|required?| +|--------|-----------|---------| +|queryType|This String should always be "dataSourceMetadata"; this is the first thing Druid looks at to figure out how to interpret the query|yes| +|dataSource|A String defining the data source to query, very similar to a table in a relational database|yes| +|context|An additional JSON Object which can be used to specify certain flags.|no| + +The format of the result is: + +```json +[ { + "timestamp" : "2013-05-09T18:24:00.000Z", + "result" : { + "maxIngestedEventTime" : "2013-05-09T18:24:09.007Z", + } +} ] +``` diff --git a/docs/content/toc.textile b/docs/content/toc.textile index 87a4fd12370..2e096adf717 100644 --- a/docs/content/toc.textile +++ b/docs/content/toc.textile @@ -52,6 +52,7 @@ h2. Querying ** "Granularities":./Granularities.html ** "DimensionSpecs":./DimensionSpecs.html * Query Types +** "DataSourceMetadataQuery":./DataSourceMetadataQuery.html ** "GroupBy":./GroupByQuery.html *** "LimitSpec":./LimitSpec.html *** "Having":./Having.html diff --git a/processing/src/test/java/io/druid/query/datasourcemetadata/DataSourceMetadataQueryTest.java b/processing/src/test/java/io/druid/query/datasourcemetadata/DataSourceMetadataQueryTest.java index 03974cf54f0..0d5a941afce 100644 --- a/processing/src/test/java/io/druid/query/datasourcemetadata/DataSourceMetadataQueryTest.java +++ b/processing/src/test/java/io/druid/query/datasourcemetadata/DataSourceMetadataQueryTest.java @@ -28,6 +28,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.metamx.common.guava.Sequences; import io.druid.data.input.MapBasedInputRow; +import io.druid.granularity.QueryGranularity; import io.druid.jackson.DefaultObjectMapper; import io.druid.query.Druids; import io.druid.query.Query; @@ -35,10 +36,13 @@ import io.druid.query.QueryRunner; import io.druid.query.QueryRunnerFactory; import io.druid.query.QueryRunnerTestHelper; import io.druid.query.Result; +import io.druid.query.aggregation.AggregatorFactory; +import io.druid.query.aggregation.CountAggregatorFactory; import io.druid.query.timeboundary.TimeBoundaryQueryQueryToolChest; import io.druid.segment.IncrementalIndexSegment; import io.druid.segment.TestIndex; import io.druid.segment.incremental.IncrementalIndex; +import io.druid.segment.incremental.OnheapIncrementalIndex; import io.druid.timeline.LogicalSegment; import org.joda.time.DateTime; import org.joda.time.Interval; @@ -107,7 +111,9 @@ public class DataSourceMetadataQueryTest @Test public void testMaxIngestedEventTime() throws Exception { - final IncrementalIndex rtIndex = TestIndex.getIncrementalTestIndex(false); + final IncrementalIndex rtIndex = new OnheapIncrementalIndex( + 0L, QueryGranularity.NONE, new AggregatorFactory[]{new CountAggregatorFactory("count")}, 1000 + );; final QueryRunner runner = QueryRunnerTestHelper.makeQueryRunner( (QueryRunnerFactory) new DataSourceMetadataQueryRunnerFactory( QueryRunnerTestHelper.NOOP_QUERYWATCHER