Skip to content

Commit

Permalink
Set default query granularity for null value (apache#3965)
Browse files Browse the repository at this point in the history
  • Loading branch information
jihoonson authored and gianm committed Feb 23, 2017
1 parent f21641f commit ebd100c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 2 additions & 3 deletions docs/content/ingestion/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ handle all formatting decisions on their own, without using the ParseSpec.

## GranularitySpec

The default granularity spec is `uniform`.
The default granularity spec is `uniform`, and can be changed by setting the `type` field.
Currently, `uniform` and `arbitrary` types are supported.

### Uniform Granularity Spec

This spec is used to generated segments with uniform intervals.

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| type | string | The type of granularity spec. | no (default == 'uniform') |
| segmentGranularity | string | The granularity to create segments at. | no (default == 'DAY') |
| queryGranularity | string | The minimum granularity to be able to query results at and the granularity of the data inside the segment. E.g. a value of "minute" will mean that data is aggregated at minutely granularity. That is, if there are collisions in the tuple (minute(timestamp), dimensions), then it will aggregate values together using the aggregators instead of storing individual rows. | no (default == 'NONE') |
| rollup | boolean | rollup or not | no (default == true) |
Expand All @@ -196,7 +196,6 @@ This spec is used to generate segments with arbitrary intervals (it tries to cre

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| type | string | The type of granularity spec. | no (default == 'uniform') |
| queryGranularity | string | The minimum granularity to be able to query results at and the granularity of the data inside the segment. E.g. a value of "minute" will mean that data is aggregated at minutely granularity. That is, if there are collisions in the tuple (minute(timestamp), dimensions), then it will aggregate values together using the aggregators instead of storing individual rows. | no (default == 'NONE') |
| rollup | boolean | rollup or not | no (default == true) |
| intervals | string | A list of intervals for the raw data being ingested. Ignored for real-time ingestion. | yes for batch, no for real-time |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.PeekingIterator;
import com.google.common.collect.Sets;

import io.druid.common.utils.JodaUtils;
import io.druid.granularity.QueryGranularities;
import io.druid.granularity.QueryGranularity;
import io.druid.java.util.common.Granularity;
import io.druid.java.util.common.guava.Comparators;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Interval;
Expand All @@ -57,7 +56,7 @@ public ArbitraryGranularitySpec(

)
{
this.queryGranularity = queryGranularity;
this.queryGranularity = queryGranularity == null ? QueryGranularities.NONE : queryGranularity;
this.rollup = rollup == null ? Boolean.TRUE : rollup;
this.intervals = Sets.newTreeSet(Comparators.intervalsByStartThenEnd());
this.timezone = timezone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ public class ArbitraryGranularityTest
{
private static final ObjectMapper jsonMapper = new DefaultObjectMapper();

@Test
public void testDefaultQueryGranularity()
{
final GranularitySpec spec = new ArbitraryGranularitySpec(
null,
Lists.newArrayList(
new Interval("2012-01-08T00Z/2012-01-11T00Z"),
new Interval("2012-02-01T00Z/2012-03-01T00Z"),
new Interval("2012-01-07T00Z/2012-01-08T00Z"),
new Interval("2012-01-03T00Z/2012-01-04T00Z"),
new Interval("2012-01-01T00Z/2012-01-03T00Z")
));
Assert.assertNotNull(spec.getQueryGranularity());
}

@Test
public void testSimple()
{
Expand Down

0 comments on commit ebd100c

Please sign in to comment.